Skip to content

Instantly share code, notes, and snippets.

@fredpalmer
Created November 16, 2010 23:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredpalmer/702728 to your computer and use it in GitHub Desktop.
Save fredpalmer/702728 to your computer and use it in GitHub Desktop.
How to bypass a decorator in Python
# Bypass a decorator
import types
class decorator_test(object):
def __init__(self, f):
self.f = f
def __call__(self):
print "In decorator ... entering: ", self.f.__name__
self.f()
print "In decorator ... exiting: ", self.f.__name__
@decorator_test
def func1():
print "inside func1()"
print "\nCalling func1 with decorator..."
func1()
print "\nBypassing decorator..."
for value in func1.__dict__.values():
if isinstance(value, types.FunctionType) and value.func_name == "func1":
value.__call__()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment