這裏是代碼我不明白:
def coroutine(func):
def start(*args,**kwargs):
cr = func(*args, **kwargs)
#cr.next()
next(cr)
return cr
return start
@coroutine #<<<----- HERE
def detectChange(value):
old_value = value
while True:
new_value = (yield)
if new_value != old_value:
print ("Ouch!")
old_value = new_value
什麼是@coroutine意味着語法明智?
http://www.dabeaz.com/coroutines/你可以看看這裏 – Almo 2012-03-08 18:49:25
您還應該張貼實際的代碼。此代碼具有無效的縮進。使用複製/粘貼。 – 2012-03-08 18:52:48