Created
December 5, 2013 19:51
-
-
Save theY4Kman/7812677 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 generate_functions import * |
This file contains hidden or 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
| import sys | |
| def generate_function(fn): | |
| module = sys.modules[fn.__module__] | |
| setattr(module, fn.__name__ + '_bar', 'bar') | |
| return fn | |
| @generate_function | |
| def foo(): | |
| pass |
This file contains hidden or 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
| 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