> > Based on Guido's positive response, in which he asked me to make > > an addition to the PEP, i believe Guido agrees with me that > > __iter__ is distinct from the protocol of an iterator. This > > surprised me because it runs counter to the philosophy previously > > expressed in the PEP. > > I recognize that they are separate protocols. But because I like the > for-loop as a convenient way to get all of the elements of an > iterator, I want iterators to support __iter__. Is this the only reason iterators are required to support __iter__? It seems like a strange design decision to put the burden on all iterator implementers to write a dummy method returning self instead of just checking if tp_iter==NULL in PyObject_GetIter. It's like requiring all class writers to write a dummy __str__ method that calls __repr__ instead of implementing the automatic fallback to __repr__ in PyObject_Str when no __str__ is available. 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