Yariv
Yariv

Reputation: 389

How to get the current value of tqdm?

How do I get an updated tqdm.n? This code seems to work:

from tqdm import tqdm
pbar = tqdm(range(10000))
for i in pbar:
     pbar.refresh()
     print 'pbar', pbar.n

Do I have to call tqdm.refresh()?

Upvotes: 2

Views: 9587

Answers (1)

vozman
vozman

Reputation: 1414

This seems to work

from tqdm import tqdm
class TqdmSpy(tqdm):
    @property
    def n(self):
        return self.__n

    @n.setter
    def n(self, value):
        print(value, self.total)
        self.__n = value

Upvotes: -1

Related Questions