How to prevent BrokenPipeError when doing a flush in Python?
How to prevent BrokenPipeError when doing a flush in Python? Question: Question: Is there a way to use flush=True for the print() function without getting the BrokenPipeError? I have a script pipe.py: for i in range(4000): print(i) I call it like this from a Unix command line: python3 pipe.py | head -n3000 And it returns: …