Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Created December 5, 2013 19:51
Show Gist options
  • Select an option

  • Save theY4Kman/7812677 to your computer and use it in GitHub Desktop.

Select an option

Save theY4Kman/7812677 to your computer and use it in GitHub Desktop.
from generate_functions import *
import sys
def generate_function(fn):
module = sys.modules[fn.__module__]
setattr(module, fn.__name__ + '_bar', 'bar')
return fn
@generate_function
def foo():
pass
import collect_functions
print 'foo_bar' in dir(collect_functions)
# True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment