Thoughts on PEP284

Raymond Hettinger vze4rx4y at verizon.net
Tue Sep 23 19:28:43 EDT 2003


[Stephen Horne]
> Running with this idea, how about...
>
>   for i in int.backward [:n] :
>     ...


I would support adding a iter_backwards() method to
strings, lists, and xrange objects.

    for i in xrange(n).iter_backwards():
            print i

    for i in range(n).iter_backwards():
            print i

    for c in "flog".iter_backwards():
            print c

It could also be implemented for other sequence objects
if there were compelling use cases and if the implementation
wasn't too hairy (file objects for instance).


Raymond Hettinger






More information about the Python-list mailing list