On Tue, Jul 09, 2002 at 08:14:38AM -0400, François Pinard wrote: > This is all clear to me, except for one little thing. I wonder why class > `ifile' has an `__iter__' method itself. I know it is said to be the > "iterator protocol", and I wonder why it has to be. I don't like it either. In my previous message about the language 'Mamba' in an alternative universe I have an example of an alternative: if object has a tp_iter it is called, otherwise the object must have a tp_next. > My understanding is that `__iter__' returns an iterator all ready to be > enquired a number of times through `.next()' calls, and I presume that > if any re-initialisation has to take place, it is within `__iter__'. > 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. > Would it make sense using the iterator `__iter__' as the preferred place > where it re-initialises itself? As far as I can tell this was done so that for could iterate over both iterables and iterators. I just don't see why it has to be done by all iterators instead of in just one place, adding much confusion between iterators and iterables in the process. Oren
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