discarded iterator.next() at interactive global scope doesn't bump interator??
Peter Otten
__peter__ at web.de
Sun Sep 4 04:10:33 EDT 2005
Bengt Richter wrote:
[it.next() appears to be a noop in the interactive interpreter]
> I guess it could be in the read-eval-print loop
Indeed:
>>> for i in range(5):
... 42
...
42
42
42
42
42
Whereas:
>>> for i in range(5):
... None
>>>
Every line with an expression that doesn't evaluate to None is echoed.
Therefore
it.next()
and
print it.next()
look the same when repr(it.next()) == str(it.next()).
No bug :-)
Peter
More information about the Python-list
mailing list