Hacker News new | ask | show | jobs
by comex 4669 days ago
Note that in Python you usually use the syntactic sugar of for loops rather than interacting with StopIteration manually.
1 comments

True! I should have made that clearer.

The only time you need to think about StopIteration is if you're consuming from an iterator in some unusual way (eg writing a "get me the single item which is in this iterator, or blow up if there are zero or more than one" function) or if you're writing an iterator which is not built out of building blocks which already know how to stop an iteration.

So, not often.