I have a generator that generates a series, for example:
def triangleNums():
'''generate series of triangle numbers'''
tn = 0
counter = 1
while(True):
tn = tn + counter
yield tn
counter = counter + 1
in python 2.6 I am able to make the following calls:
g = triangleNums() # get the generator
g.next() # get next val
however in 3.0 if I execute the same two lines of code I'm getting the following error:
AttributeError: 'generator' object has no attribute 'next'
but, the loop iterator syntax does work in 3.0
for n in triangleNums():
if not exitCond:
doSomething...
I've not been able to find anything yet that explains this difference in behavior for 3.0.