Skip to content

Instantly share code, notes, and snippets.

@stnbu
Created December 15, 2014 20:24
Show Gist options
  • Save stnbu/d7a8965792c4c2cbe45d to your computer and use it in GitHub Desktop.
Save stnbu/d7a8965792c4c2cbe45d to your computer and use it in GitHub Desktop.
Trivial python decorator examples. Because I always forget.
def decorator(orig_func):
"""Trivial python decorator
"""
def wrapper_func(*a, **k):
return orig_func(*a, **k)
return wrapper_func
def decorator_wrapper(arg):
"""Decorator with arg(s). Do something conditional/interesting with "arg"
"""
def decorator(orig_func):
def wrapper_func(*a, **k):
return orig_func(*a, **k)
return wrapper_func
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment