import weakref class AttributeAccess(object): def __init__(self, container, accessor='__getattr__'): mydict = self.__dict__ mydict['__container'] = weakref.ref(container) mydict['__accessor'] = accessor def __getattr__(self, name): container = self.__dict__['__container']() accessor = self.__dict__['__accessor'] return getattr(container, accessor)(name) ## Local Variables: ## mode: python ## py-indent-offset: 4 ## tab-width: 4 ## fill-column: 72 ## End: