Skip to content

Instantly share code, notes, and snippets.

@josemarcosrf
Created November 26, 2018 18:22
Show Gist options
  • Save josemarcosrf/0e49a8346d6ba99e6378b820f6f5dc31 to your computer and use it in GitHub Desktop.
Save josemarcosrf/0e49a8346d6ba99e6378b820f6f5dc31 to your computer and use it in GitHub Desktop.
python @wraps example of use
from functools import wraps
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
print("I am the wrapper, wrapping '{}'".format(f.__name__))
return f(*args, **kwargs)
return wrapper
@decorator
def hello(name):
print("Hey there {}".format(name))
hello("world")
# I am the wrapper, wrapping 'hello'
# Hey there marcos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment