updated from Atlas
This commit is contained in:
16
09-closure-deco/clock/clockdeco_demo.py
Normal file
16
09-closure-deco/clock/clockdeco_demo.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import time
|
||||
from clockdeco0 import clock
|
||||
|
||||
@clock
|
||||
def snooze(seconds):
|
||||
time.sleep(seconds)
|
||||
|
||||
@clock
|
||||
def factorial(n):
|
||||
return 1 if n < 2 else n*factorial(n-1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('*' * 40, 'Calling snooze(.123)')
|
||||
snooze(.123)
|
||||
print('*' * 40, 'Calling factorial(6)')
|
||||
print('6! =', factorial(6))
|
||||
Reference in New Issue
Block a user