Skip to content

Instantly share code, notes, and snippets.

@santosh
Last active May 21, 2018 19:33
Show Gist options
  • Save santosh/e33d77799f925b043eaabe414fdc0204 to your computer and use it in GitHub Desktop.
Save santosh/e33d77799f925b043eaabe414fdc0204 to your computer and use it in GitHub Desktop.
Procedurally learning the decorators.
def greeting(expr):
def greeting_decorator(func):
def function_wrapper(x):
print(expr + ", " + func.__name__ + " returns:")
func(x)
return function_wrapper
return greeting_decorator
@greeting("καλημερα")
def foo(x):
print(42)
foo("Hi")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment