No, it is not. This is the result:
>>> s=sp()
>>> s
<generator object sp at 0x102d1c690>
>>> s.next()
0
>>> s.next()
0
>>> s.next()
1
>>> s.next()
0
>>> s.next()
1
>>> s.next()
2
>>> s.next()
0
>>> s.next()
1
>>> s.next()
2
>>> s.next()
3
>>> s.next()
0
>>> s.next()
1
>>> s.next()
2
>>> s.next()
3
>>> s.next()
4
which is to be expected. Each time you start from 0 and go to some one i, and then again return from 0 to the next value i.
source
share