1
爲什麼這段代碼不起作用?python裝飾器,調用延遲功能
from threading import Timer
def delayed(seconds):
def decorator(f):
def wrapper(*args, **kargs):
Timer(seconds, f, args, kargs)
return wrapper
return decorator
@delayed(1)
def foo():
'''this function does not return'''
print('foo')
foo()
print('dudee')
我只是這樣的結果: dudee 富
我只有 dudee
OHU神!我在沒有實例化的情況下檢查dir(Timer)!謝謝! – nkint 2011-03-06 12:12:06