I'm using tqdm as I recurse over a directory tree. I don't know the number of paths I'll be using, and I don't want to build that list before I do the work just to get an accurate total count, I'd rather have it just update the progress bar as it goes along.
I've found that I can use 'reset(total=new_total)' just fine, but that also resets the time. Is there a way I can keep the time but just set the total to something new?
Here is the definition of reset
function definition inside tqdm
package:
def reset(self, total=None):
"""
Resets to 0 iterations for repeated use.
Consider combining with `leave=True`.
Parameters
----------
total : int, optional. Total to use for the new bar.
"""
self.last_print_n = self.n = 0
self.last_print_t = self.start_t = self._time()
if total is not None:
self.total = total
self.refresh()
What you need is not to update values of self.last_print_t
, and self.start_t
and just update the total
Instead of calling t.reset(total=new_total)
, you should do the following:
t.total = new_total
t.refresh()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With