I have a script to download some files with urllib.request.urlretrieve
and I use tqdm
for my progress bar and that work fine, except when I use in the IDLE because there the others control characters like '\r'
or '\b'
don't work properly and as result the output is ugly
that is
IDLE
>>> print('abc\rXXX')
abc\rXXX
>>> print('abc\b\b\bXXX')
abc\b\b\bXXX
>>>
terminal/cmd
>>> print('abc\rXXX')
XXX
>>> print('abc\b\b\bXXX')
XXX
>>>
my question is, how I can detect when '\r'
will work properly??
so I can do something like this
from tqdm import tqdm, tqdm_gui
if control_char_work_fine():
progress_bar = tqdm
else:
progress_bar = tqdm_qui
or if that is no possible how to detect when I am in the IDLE?