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

Alex Martelli aleaxit at yahoo.com
Tue Nov 4 17:09:24 EST 2003

On Tuesday 04 November 2003 10:57 pm, Delaney, Timothy C (Timothy) wrote:
> > From: Alex Martelli [mailto:aleaxit at yahoo.com]
> >
> > or reversed(enumerate(seq)) if the index IS needed.
> Hmm - wouldn't this give an iterator that returned two values - an iterable
> for the seq, and an iterable for the indexes of seq?

I must be missing something.  enumerate(x) is an iterator with len(x)
values, each a pair; why would reversing it somehow "transpose" it...?

> I would think this would need to be:
>     reversed(*enumerate(seq))
> with the presumption being that reversed would reverse each parameter and
> return them in lockstep.

I'm not sure if reversed should take several parameters, but it if did this
would be like calling:
    reversed( (0, x[0]), (1,x[1]), (2,x[2]) )
If it "reversed each parameter and returned them in lockstep" then I'd
have x first and (0,1,2) second, no?


More information about the Python-Dev mailing list