Generator

mattia gervaz at gmail.com
Sun Mar 22 14:15:02 CET 2009


Can you explain me this behaviour:

>>> s = [1,2,3,4,5]
>>> g = (x for x in s)
>>> next(g)
1
>>> s
[1, 2, 3, 4, 5]
>>> del s[0]
>>> s
[2, 3, 4, 5]
>>> next(g)
3
>>>

Why next(g) doesn't give me 2?



More information about the Python-list mailing list