Fix Python – Can I redirect the stdout into some sort of string buffer?

I’m using python’s ftplib to write a small FTP client, but some of the functions in the package don’t return string output, but print to stdout. I want to redirect stdout to an object which I’ll be able to read the output from.
I know stdout can be redirected into any regular file with:
stdout = open(“file”, “a”)

But I prefer a method that doesn’….

Fix Python – Redirecting to URL in Flask

I’m new to Python and Flask and I’m trying to do the equivalent of Response.redirect as in C# – ie: redirect to a specific URL – how do I go about this?
Here is my code:
import os
from flask import Flask

app = Flask(__name__)

@app.route(‘/’)
def hello():
return ‘Hello World!’

if __name__ == ‘__main__’:
# Bind to PORT if defined, otherwi….