Reversing an iterator with older version of Python

Aki Niimura akineko at pacbell.net
Wed Nov 12 13:22:12 EST 2003


Hello everyone,

I need to reverse an iterator in my program.

There are many posting to related to this. But most of them are
talking about how to expand the language to support such. In fact
reversed() built-in function is added in Python 2.4 to do such.

However, I need to use Python 2.2.x because of a module I'm using.

I can think of very crude way to reverse the iterator. But I don't
like it.
(It is so crude such that I'm ashamed to show it here)

Is there any elegant way to reverse an iterator using the features
available in older Python, such as Python 2.2.

These day, things are moving too fast to follow.

Any suggestions are highly appreciated.

Best regards,
Aki Niimura




More information about the Python-list mailing list