Can I add message to the tqdm progressbar?

Dror Hilman picture Dror Hilman · May 29, 2016 · Viewed 68.3k times · Source

When using the tqdm progress bar: can I add a message to the same line as the progress bar in a loop?

I tried using the "tqdm.write" option, but it adds a new line on every write. I would like each iteration to show a short message next to the bar, that will disappear in the next iteration. Is this possible?

Answer

Ghrua picture Ghrua · Aug 5, 2017

The example shown in Usage of tqdm works well for me.

pbar = tqdm(["a", "b", "c", "d"])
for char in pbar:
    pbar.set_description("Processing %s" % char)