I'm using tqdm in Python to display console progress bars.
I have a function from another library that occasionally writes to both stdout and stderr inside the tqdm loop. I cannot hack the source code of that function.
While this doc shows how to redirect sys.stdout, it doesn't easily generalize to stderr because I can pass only one of stdout or stderr to the file=
parameter in tqdm's __init__
. Please refer to this question and its accepted answer for the minimal code that illustrates the problem.
How do I redirect both stdout and stderr together?