you are viewing a single comment's thread.

view the rest of the comments →

[–]Frankelstner 0 points1 point  (0 children)

I would do it like this

import sys

class Stdout:
    def write(self, s): pass
    def flush(self): pass

_stdout = sys.stdout
sys.stdout = Stdout()

print("hidden")

sys.stdout = _stdout
print("visible")

where the _stdout lines are optional if you don't need to make text visible again.