Created
August 4, 2012 03:14
-
-
Save dcrosta/3253877 to your computer and use it in GitHub Desktop.
Use a Python class as a fake module
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
import sys | |
class TheModule(object): | |
def __getattr__(self, name): | |
# you can do whatever you want with `name` here | |
print (self, name) | |
sys.modules[__name__] = TheModule() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment