discarded iterator.next() at interactive global scope doesn't bump interator??

Bengt Richter bokr at oz.net
Sun Sep 4 14:17:20 CEST 2005


On Sun, 04 Sep 2005 10:10:33 +0200, Peter Otten <__peter__ at web.de> wrote:

>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 :-)
>
D'oh. I said it, but I didn't hear myself ;-/

Regards,
Bengt Richter



More information about the Python-list mailing list