I was trying to implement a function generator to be used n times. My idea was to create a generator object, then assign that object to another variable and call the re-assigned variable as the function, example:
def generator:
[...]
yield ...
for x in xrange(10):
function = generator
print function(50)
When I call the print function, I observe that function(50)
was not called. Instead the output is: <generator object...>
. I was trying to use this function 10 times by assigning it to a generator function, and using this new variable as the generator function.
How can I correct this?