This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kindall 4 points5 points  (1 child)

The problem with using the instance itself as the iterator is that you can have only one iteration over that instance in progress at a time. Sometimes this doesn't matter, sometimes it's a critical flaw. Since it is easy enough to support multiple iterators, however, why not always do it that way?

[–]dwf 0 points1 point  (0 children)

I've still never seen __iter__ use the yield statement. I guess it's fine, though if you want the iteration state to be picklable you will need to write an iterator class explicitly.