[Python-Dev] PEP 322: Reverse Iteration

Guido van Rossum guido at python.org
Mon Nov 3 18:26:32 EST 2003

> > BTW, Alex said he was +1 on the idea, but only +0 on it being a builtin.
> Uh, did I?  OK maybe I did.  But what about "revrange" (which I'd LOVE
> to incarnate as an iterator-returning irange with an optional reverse=
> argument) -- was that knocked out of contention?  I claimed that just
> revrange would be too specialized BUT irange would be JUST RIGHT...

This surprised me a bit too.  The majority of Raymond's examples in
the PEP (when I last saw it a week ago) were reverse numeric ranges,
usually of the form revrange(n) -- which we currently have to spell as
range(n-1, -1, -1) (I think :-) and which the new proposal would turn
into reversed(range(n)).  According to Raymond, a built-in that would
do just that only drew (a small number of) negative responses in the

Such a thing would face zero opposition if it was part of itertools:
itertools.revrange([start, ] stop[, step]) makes total sense to me...

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

More information about the Python-Dev mailing list