1 2 3 4 5
import io # test __enter__/__exit__ with io.StringIO() as b: b.write("foo") print(b.getvalue())