MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / decorate

Function decorate

09-closure-deco/registration_param.py:6–14  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

4
5def register(active=True): # <2>
6 def decorate(func): # <3>
7 print('running register'
8 f'(active={active})->decorate({func})')
9 if active: # <4>
10 registry.add(func)
11 else:
12 registry.discard(func) # <5>
13
14 return func # <6>
15 return decorate # <7>
16
17@register(active=False) # <8>

Callers

nothing calls this directly

Calls 1

addMethod · 0.80

Tested by

no test coverage detected