I've been needing a module level __getattr__ for some c library
wrapping. This has solved the problem:
# mymod.py:
import sys
from new import module
class ModuleProxy(module):
def __init__( self, name, master ):
module.__init__( self, name )
self._master = master
self.__dict__["__all__"] = dir(master)
def __getattr__(self, name):
attr = getattr( self._master, name )
return attr
# ... end of file:
sys.modules["mymod"] = ModuleProxy("mymod",sys.modules["mymod"])
--Simon Burton
--
http://mail.python.org/mailman/listinfo/python-list