decorator¶
- Make a wrapper for function and provide a syntatic sugar
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
functools.wrap()
usesfunctools.update_wrapper()
to update attributes like__name__
and__doc__
for type introspection
- Usage for e.g.: debug print, timing, lightweight plugin system
TODO
References¶
Primer on Python Decorators
https://realpython.com/primer-on-python-decorators/