I created a simple generator:
def long_time():
for i in range(10):
yield i * 5
a = long_time()
print(next(a))
print(next(a))
Here, I get the outputs 0 and 5, which is OK. But when I try to build the variable a as below:
def long_time():
for i in range(10):
yield i * 5
a = long_time
print(next(a()))
print(next(a()))
Both of the print outputs are 0. What is the difference, should I always call the generator with ()?