When working with tqdm for a project, I've noticed that when I use a print statement just before I call a function that has a tqdm progress bar, the print statement is printed somewhere in between the progress bars.
I've noticed that this behaviour only occurs in ipython notebooks, not when run in terminal.
from tqdm import tqdm
def long_progress():
for _ in tqdm(range(100)):
time.sleep(.05)
for i in range(5):
print("Show parameters of the progress")
long_progress()
This behaviour doesn't break anything, I'm just really curious why it is happening.
I've also noticed that when I use time.sleep(0.2)
before I call tqdm it's resolved, so it seems like some timing issue.
Edit: Changed print statement to reflect my goal more precisely
Define the print statement outside the loop ie
print("Lets start long progress")
for i in range(5):
long_progress()
This will call the print before the loop execution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.