[Python-Dev] Re: PEP 322: Reverse Iteration
Moore, Paul
Paul.Moore at atosorigin.com
Wed Nov 5 06:24:50 EST 2003
From: Guido van Rossum [mailto:guido at python.org]
>> 1. Add a plain irange() to itertools.
>> 2. IF the general reversed() is deemed too theoretical, add EITHER a
>> reverse argument to irange, or an irevrange to itertools. Both feel
>> to me a little iffy, but that's my generality bias again.
>> 3. IF the general reversed() is accepted (builtin or not) leave the
>> irange function in its simple form.
> Hm. reversed(irange(...)) can't work, so you'd have to have both.
Raymond is proposing (in the PEP) a custom reverse via a __reversed__
special method. I'm assuming that irange() [and enumerate(), and possibly
others] would need such a method, in order to cover just this case.
>From my POV, having reversed(enumerate()) work is essential. Also for
irange() if that is accepted. I've not looked through the other itertools,
but a trawl through those to ensure any that need it have custom reverse
methods would also be sensible.
Paul.
More information about the Python-Dev
mailing list