On PEP 322 (ireverse)

Raymond Hettinger vze4rx4y at verizon.net
Thu Oct 30 00:36:15 EST 2003


[Jeremy Fincher]

> Why not a more
> comprehensive PEP defining a reverse iteration protocol similar the
> protocol we have now for forward iteration?

It's in there under the Custom Reverse section.  The approach is so
simple it doesn't take much elaboration:  Objects may define a
__ireverse__ method that returns a reverse iterator -- this allows
objects without __getitem__ and __len__ to participate in
reverse iteration.


Raymond Hettinger











More information about the Python-list mailing list