I would like some way to print()
to a string or internal buffer rather than stdout in Python.
Ideally, I could print to this and later dump the string to the console just as if it had been printed to stdout to begin with. Something like:
>>> print("output 1", a)
>>> print("output 2", a)
>>> print(a)
output 1
output 2
If you're wondering, I'm doing this for the sake of quick refactoring on code that previously printed directly to the console.