Skip to content

Conversation

@TobiX
Copy link
Contributor

@TobiX TobiX commented Jul 31, 2016

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
Copy link
Contributor Author

TobiX commented Jul 31, 2018

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

test_progress.py Outdated
bar = bar_cls(bar_cls.__name__, suffix=suffix)
for i in bar.iter(range(200)):
sleep()
with bar_cls(bar_cls.__name__, suffix=suffix) as bar:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should pass a max=200 here

@verigak
Copy link
Owner

verigak commented Aug 1, 2018

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
Copy link
Contributor Author

TobiX commented Aug 1, 2018

Doh' - fixed :)

@verigak verigak merged commit d407334 into verigak:master Aug 1, 2018
@verigak
Copy link
Owner

verigak commented Aug 1, 2018

Thanks!

@TobiX TobiX deleted the contextmanager branch August 1, 2018 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants