On Fri, 19 Jul 2002, Aahz wrote: >And how does that integer index change? The for loop in Python <2.2 has >an internal state object. Iterators are the external manifestation of >that state object, generalized to objects other than sequences. I'm >surprised that anyone is surprised that the state object gets >mutated/destroyed. I'm also surprised that people are surprised about >what happens when that state object is coupled to an inherently mutating >object such as file objects. All the surprises I see stem from confusion between what is the object being iterated over, and what is the object holding the state of the iteration. Iterators returning self for __iter__() is the major cause of this confusion. I agree that in the general case, the boundary may not always be clear, but Ping's proposal cleans up what's seen 99.9% of the time. Pending the pain of the yet unseen migration plan, I'm +1 on removing __iter__ from all core iterators +1 on renaming next() to __next__() +1 on presenting file objects as iterators rather than iterables +0 on the new 'for x from y' syntax /Paul
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4