Iterator slicing?

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Fri Mar 15 19:21:05 EST 2002


Just a thought -- not sure exactly how to implement it (to avoid
conflicts with __getitem__, for instance) -- but what if iterators
were subscriptable? E.g. someiter[5:10] would return a new iteratr
which first (automatically) iterated over someiter's first five
elements (without returning them), then behave like a normal iterator
for the next five items, and then raised a StopIteration...?
Similarly, indexing an iterator could return a single value,
perhaps...

Or perhaps this is better suited for a specific wrapper in the
(possibly) upcoming iterator module... Hm.

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list