Skip to content

Instantly share code, notes, and snippets.

@clayg
Created June 13, 2012 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/2921582 to your computer and use it in GitHub Desktop.
Save clayg/2921582 to your computer and use it in GitHub Desktop.
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