Created
August 27, 2008 19:32
-
-
Save inklesspen/7564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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