Skip to content

Instantly share code, notes, and snippets.

@rainbowbird
Created February 22, 2020 13:05
Show Gist options
  • Save rainbowbird/73ba7ee2af1867944bad0fe7da5baef8 to your computer and use it in GitHub Desktop.
Save rainbowbird/73ba7ee2af1867944bad0fe7da5baef8 to your computer and use it in GitHub Desktop.
Python decorators - Application of closures
import functools
def decorator(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
print('decorator was here')
return func(*args, **kwargs)
return new_func
@decorator
def add(a, b):
return a + b
print(add(2, 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment