Skip to content

Instantly share code, notes, and snippets.

@dcrosta
Created August 4, 2012 03:14
Show Gist options
  • Save dcrosta/3253877 to your computer and use it in GitHub Desktop.
Save dcrosta/3253877 to your computer and use it in GitHub Desktop.
Use a Python class as a fake module
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