Esempio di un decoratore

This commit is contained in:
Fabio Scotto di Santolo
2021-07-01 20:05:54 +02:00
parent b02c6c1252
commit cdd79e5f15
2 changed files with 19 additions and 0 deletions

0
decorators/__init__.py Normal file
View File

19
decorators/main.py Normal file
View File

@@ -0,0 +1,19 @@
def my_decorator(f):
def wrap():
print('It has a decorator')
f()
return wrap
@my_decorator
def my_func():
print("The function my_func")
def main():
my_func()
if __name__ == '__main__':
main()