I am compiling stderr from my script to later save to the database with:
ostderr = sys.stderr
sys.stderr = StringIO()
# do stuff
mymodel.errors = sys.stderr.getvalue()
mymodel.save()
print mymodel.errors
sys.stderr = ostderr
Unfortunately, this makes it difficult to accidentally debug, because if any errors occur, I will not see them until the script completes.
How do I remove stderr in a string, as I do above, but still display it in real time on the console?
Cerin source
share