Why does this
a = (i for i in range(2))
b = a
c = a
for i in b:
print("ok")
next(c)
result in this?
StopIteration Traceback (most recent call last)
<ipython-input-37-9c481bb09894> in <module>()
54 for i in b:
55 print("ok")
---> 56 next(c)
StopIteration:
I'm currently learning about generators in python. My goal here was to set up a as a generator, make b, and c instances of a and use b and c separately. What went wrong?
Additionally, everything went well when I set up something similar with a function using yield instead of the () based generator a.