Skip to content

Instantly share code, notes, and snippets.

@inklesspen
Created August 27, 2008 19:32
Show Gist options
  • Save inklesspen/7564 to your computer and use it in GitHub Desktop.
Save inklesspen/7564 to your computer and use it in GitHub Desktop.
from decorator import decorator
import types
@decorator
def hello_printer(f, *args, **kwargs):
print "Hello World"
return f(*args, **kwargs)
def testing(name, bases, dict):
for key, value in dict.iteritems():
if isinstance(value, types.FunctionType) and not key.startswith("_"):
print "decorating " + key
dict[key] = hello_printer(value)
return type(name, bases, dict)
class Settings(object):
__metaclass__ = testing
def m(self):
print "m!"
Settings().m()
# >>> Settings().m()
# Hello World
# m!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment