I have the exact same question as Python + Disabled print output, and can't get it back. I used the following code to suppress printing:
# Disable
def blockPrint():
sys.stdout = open(os.devnull, 'w')
# Restore
def enablePrint():
sys.stdout = sys.__stdout__
The top solution to this question was to store the old stdin
by the following line, but I have already disabled printing. How can I restore this?
sys.__stdout__ = sys.stdout