I found this question about iterator behavior in Python:
Python list iterator behavior and next(iterator)
When I typed in the code:
a = iter(list(range(10)))
for i in a:
print a
next(a)
into the jupyter-qtconsole
it returned:
0
2
4
6
8
exactly as Martijn Pieters said it should when the interpreter doesn't echo the call to next(a)
.
However, when I ran the same the code again in my Bash interpreter and IDLE, the code printed:
0
1
2
3
4
5
6
7
8
9
to the console.
I ran the code:
import platform
platform.python_implementation()
in all three environments and they all said I ran 'CPython'
.
So why does the QtConsole suppress the next(a)
call when IDLE and Bash don't?
If it helps, I'm running Python 2.7.9 on Mac OSX and using the Anaconda distribution.