Re: On PEP 322 (ireverse)
[Jeremy Fincher]
[color=blue]
> Why not a more
> comprehensive PEP defining a reverse iteration protocol similar the
> protocol we have now for forward iteration?[/color]
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
[Jeremy Fincher]
[color=blue]
> Why not a more
> comprehensive PEP defining a reverse iteration protocol similar the
> protocol we have now for forward iteration?[/color]
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
Comment