I am writing a program in which an operation takes a few seconds (loading a large file). Luckily, it always takes the same amount of time. So, for the sake of the user, I want to make a progress bar. However, tqdm
seems to be designed for loops. Let's say that sleep(10)
is the process that takes time. How do I work this out?
I want to make a progress bar for a long process that is not a loop.
from time import time, sleep
from tqdm import tqdm
for i in tqdm([1]):
sleep(10)
The problem with this code is that the progress bar will stay at zero, then jump to 100% at the end of the process. I want a progress bar that evolves consistently over the course of 10 seconds.