终于搞懂了
Topic sourceWhy my code doesn't work?
def createCounter(): def counter(): i=0 while True: i=i+1 yield i
def caller():
return next(counter())
return caller
They are similar. But I didn't use a variable to accept function counter(). Why I cannot directly return next(counter())?
Is there any difference between:
return next(counter())
AND
c=counter() return next(c)?
I cannot understand this.
- 1
虚无书生666
def createCounter():