Skip to content

Instantly share code, notes, and snippets.

@kasima
Created October 18, 2010 09:42
Show Gist options
  • Save kasima/631977 to your computer and use it in GitHub Desktop.
Save kasima/631977 to your computer and use it in GitHub Desktop.
Favorite piece of code I wrote last week
# double closures - what does it mean!?
def if_braintree_disabled(default):
def generate_decorator(f):
def decorator(*args, **kwargs):
if not settings.LIVE_SITE and not settings.BRAINTREE_ENABLED:
return default
else:
return f(*args, **kwargs)
return decorator
return generate_decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment