verigak / progress

Easy to use progress bars for Python
ISC License
1.41k stars 179 forks source link

Allow usage as a context manager. #29

Closed TobiX closed 6 years ago

TobiX commented 8 years ago

Using a context manager you get exception management for free. I adjusted iter() and one of the samples to use the context manager.

Regarding iter() - would it be valuable to also make the non-infinite classes iterable themselves?

This would allow code like this:

for i in Bar(max=100):
    # Do something with i
    sleep()

PS: You should probably deprecate the SigIntMixin, since it isn't useful with proper exception handling (IMHO). PPS: This is half of #11, without all the threading...

TobiX commented 6 years ago

@verigak Ping? This still applies cleanly and adds a nice feature (IMHO)

verigak commented 6 years ago

Thanks for the ping, this is indeed useful. Please see just the one comment I left in the review and then I'll be happy to merge.

TobiX commented 6 years ago

Doh' - fixed :)

verigak commented 6 years ago

Thanks!