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

Jeremy Fincher fincher.8 at osu.edu
Wed Nov 5 17:00:31 EST 2003


On Wednesday 05 November 2003 10:56 am, Alex Martelli wrote:
> def reversed(sequence):
>     for x in xrange(len(sequence)-1, -1, -1): yield sequence[x]
>
> no __reversed__, no complications, "no nuttin'".
>
> Putting that in the current 2.4 pre-alpha will let us start getting some
> experience with it and see if in the future we want to add refinements
> (always easier to add than to remove...:-) -- either to reverse or to
> other iterator-returning calls (e.g. reverse= optional arguments just
> like in the sort method of lists).

It seems like a perfect candidate for that "tools" hierarchy you proposed 
before.  As a builtin, I'd be surprised if it saw significant use.

Jeremy



More information about the Python-Dev mailing list