example-code-2e/09-closure-deco/registration_abridged.py

17 lines
286 B
Python
Raw Normal View History

2020-06-11 19:58:15 +02:00
# tag::REGISTRATION_ABRIDGED[]
registry = []
def register(func):
print(f'running register({func})')
registry.append(func)
return func
@register
def f1():
print('running f1()')
print('running main()')
print('registry ->', registry)
f1()
# end::REGISTRATION_ABRIDGED[]