Skip to content

Instantly share code, notes, and snippets.

@VerosK
Created October 1, 2021 07:25
Show Gist options
  • Save VerosK/e102dffc1031f9a88ac26bf5d94f1eb4 to your computer and use it in GitHub Desktop.
Save VerosK/e102dffc1031f9a88ac26bf5d94f1eb4 to your computer and use it in GitHub Desktop.
Art decoators
# see https://naucse.python.cz/course/mi-pyt/intro/magic/
import functools
def art_deco(func):
print(f"Decorating {func.__name__}")
@functools.wraps(func)
def inner(*args, **kwargs):
print(f"Starting {func.__name__}")
retv = func(*args, **kwargs)
print(f"Result {func.__name__} is {retv}")
return retv
return inner
@art_deco
def foo(a):
"This is very important function!"
print(f"foo: a is {a}")
return a
if __name__ == '__main__':
# print("main is starting")
print(f'foo is {foo.__name__}')
print(f'doc in foo is {foo.__doc__}')
#foo(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment