A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026850.html below:

[Python-Dev] The iterator story

[Python-Dev] The iterator storyGuido van Rossum guido@python.org
Sat, 20 Jul 2002 10:13:34 -0400
> > >     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__?

Yes.

> 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.

I suppose you meant "check for tp_iter==NULL and tp_iternext!=NULL.

--Guido van Rossum (home page: http://www.python.org/~guido/)




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