Created
November 4, 2010 22:34
-
-
Save schmir/663325 to your computer and use it in GitHub Desktop.
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
def AliasModule(modname, modpath): | |
getmod = lambda: importobj(modpath, None) # do we need caching?? | |
class AliasModule(ModuleType): | |
def __repr__(self): | |
return '<AliasModule %r for %r>' % (modname, modpath) | |
def __getattribute__(self, name): | |
return getattr(getmod(), name) | |
def __setattr__(self, name, value): | |
setattr(getmod(), name, value) | |
def __delattr__(self, name): | |
delattr(getmod(), name) | |
return AliasModule(modname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment