Sequence iterators with __index__
schickb
schickb at gmail.com
Tue Jun 24 18:29:52 EDT 2008
I think it would be useful if iterators on sequences had the __index__
method so that they could be used to slice sequences. I was writing a
class and wanted to return a list iterator to callers. I then wanted
to let callers slice from an iterator's position, but that isn't
supported without creating a custom iterator class.
Are there reasons for not supporting this generally? I realize not all
iterators would have the __index__ method, but that seems ok.
In Python 3, maybe this could be called a SequenceIterator
-Brad
More information about the Python-list
mailing list