Created
June 13, 2012 03:09
-
-
Save clayg/2921582 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
COMMANDS = {} | |
def command(f): | |
COMMANDS[f.__name__] = f | |
return f | |
@command | |
def func1(): | |
print 'func1' | |
class Basic(object): | |
@command | |
def func2(self): | |
print 'func2' | |
print func1 == COMMANDS['func1'] | |
# I expected this to work | |
print Basic.func2 == COMMANDS['func2'] | |
# not surprisingly this doesn't work, but I had to check | |
# obj = Basic() | |
# print obj.func2 == COMMANDS['func2'] | |
for name, func in (('func1', func1), ('func2', Basic.func2)): | |
print name, func | |
for name, func in COMMANDS.items(): | |
print name, func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment