68Re: [python-iter] Colon syntax: We barely knew thee...
- Mar 3, 2001On 3 Mar 2001 qrczak@... wrote:
> try: _tmp = seq.__iterator__()I can see that this would work, but i don't understand why you prefer
> except AttributeError: _tmp = indexing_iterator(seq)
> # Types with fast x[1:] can just def __iterator__(self): return self
> # Types which don't define __iterator__ get the old iteration protocol.
> while 1:
> try: x = _tmp
> except IndexError: break
> _tmp = _tmp[1:]
> indexing_iterator is a proxy which emulates sliced iteration interface
> in terms of indexed iteration interface.
iter = iter[1:]
while 1: # when a new-style iterator is available
i = 0
while 1: # what happens when we use make_iterator()
i = i + 1
as the basic stepping operation (in the above, think of "body"
as the body of the for-loop and "iter" as the iterator object).
"The biggest cause of trouble in the world today is that the stupid people
are so sure about things and the intelligent folk are so full of doubts."
-- Bertrand Russell
- << Previous post in topic Next post in topic >>