PEP 322: Reverse Iteration (REVISED, please comment)

Raymond Hettinger vze4rx4y at verizon.net
Wed Oct 29 12:51:30 EST 2003


> Since iter() constructs and returns a type 'iterator' object, I
> expected that it might be a type object, just like int(), etc.  If it
> were turned into one, like int(), etc, have been, then
 . . .
> Unless there is a good reason to not make iter a type object, then
> making it so could be part of the suggested implementation of the PEP.

iter() is a factory function that can return all kinds of things:

>>> from random import random
>>> iters = iter('str'), iter(['list']), iter(dict(a=1)), iter(random, None)
>>> map(type, iters)
[<type 'iterator'>, <type 'listiterator'>, <type 'dictionary-iterator'>, <type
'callable-iterator'>]



Let's see if we can get back to the merits of the pep.
Looking at your own code, can you verify that ireverse()
is an improvement over what you have now.


Raymond Hettinger







More information about the Python-list mailing list