[Oren Tirosh] > [François Pinard] > > However, as the iterator maintains its own progressive state, I do not see > > the intent and purpose of the iterator having an `__iter__' method itself. > As far as I can tell this was done so that for could iterate over both > iterables and iterators. That is, that an iterator is always itself an iterable. I guess the real question is: could we have the guarantee that if an iterable returns an iterator through the iterable's __iter__, the iterator's __iter__ method will never be called from looping over the iterable? If we do not have that guarantee, then, when (and why) will the iterator's __iter__ be called? I did not find an answer to these questions neither from the Reference Manual nor the PEP, yet I confess that the exposition of the C API might hold an answer I could not understand. Could it be explained without referring to C? -- François Pinard http://www.iro.umontreal.ca/~pinard
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