[Python-Dev] Re: PEP 322: Reverse Iteration

Samuele Pedroni pedronis at bluewin.ch
Wed Nov 5 10:13:49 EST 2003

At 07:02 05.11.2003 -0800, Guido van Rossum wrote:
> > Among the comp.lang.python crowd, nearly everyone supported some form of
> > the PEP (with varying preferences on the name or where to put it).  The
> > community participation rate was high with about 120 posts across four
> > threads contributing to hammering out the current version of the pep.
>How many participants in those 120 posts?  (I recall a thread where
>one individual posted 100 messages. :-)
> > Is there anything else that needs to be done in the way of research,
> > voting, or cheerleading for pep to be accepted?
>Yes.  I'm getting cold feet about __reversed__.  Some folks seem to
>think that reversed() can be made to work on many iterators by having
>the iterator supply __reversed__; I think this is asking for trouble
>(e.g. you already pointed out why it couldn't be done for

yes, but __reversed__ is meanigful for iterables not iterators

I had the impression that reversed(.) is related to iter(.) for reverse 
and __reversed__ would correspond to __iter__ also for that, but this is 
meanigful for iterables that are not already iterators.

For iterators __iter__ is typically the identity, while __reversed__ is not 
really applicable which probably means that reverse iteration is more 
complicated that forward iteration <wink>.


More information about the Python-Dev mailing list