ch08, 09, 10: example files

This commit is contained in:
Luciano Ramalho
2020-06-11 14:58:15 -03:00
parent 42861b64d8
commit bf4a2be8b9
111 changed files with 4707 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# tag::REGISTRATION_PARAM[]
registry = set() # <1>
def register(active=True): # <2>
def decorate(func): # <3>
print('running register'
f'(active={active})->decorate({func})')
if active: # <4>
registry.add(func)
else:
registry.discard(func) # <5>
return func # <6>
return decorate # <7>
@register(active=False) # <8>
def f1():
print('running f1()')
@register() # <9>
def f2():
print('running f2()')
def f3():
print('running f3()')
# end::REGISTRATION_PARAM[]