How can I archive this?

from tqdm import tqdm for link in tqdm(links): try: #Do Some Stff except: pass print("Done:") 

Result:

100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:00<00:00, 111.50it/s] Done: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:00<00:00, 111.50it/s] Done: 

Expected Result (Showing the status bar but don't print it after into the console)

Done: Done: 

2 Answers

tqdm actually takes several arguments, one of them is leave, which according to the docs:

If [default: True], keeps all traces of the progressbar upon termination of iteration. If None, will leave only if position is 0

So:

>>> for _ in tqdm(range(2)): ... time.sleep(1) ... 100%|██████████████████████████████████████████████████████| 2/2 [00:02<00:00, 1.01s/it] 

Whereas setting leave=False yields:

>>> for _ in tqdm(range(2), leave=False): ... time.sleep(1) ... >>> 

You can pass parameter disable=True.

Source:

disable: bool, optional
Whether to disable the entire progress bar wrapper [default: False]. If set to None, disable on non-TTY.

from tqdm import tqdm for link in tqdm(links,disable=True): try: #Do Some Stff except: pass print("Done:") 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy