Re: delegate functions to member

2010-08-10 Thread Ulrich Eckhardt
Peter Otten wrote: > Ulrich Eckhardt wrote: >> So, short follow-up question: Why does this work? > > __getattr__() is a fallback that is only tried when the normal lookup > fails. If you need to intercept every attribute lookup use > __getattribute__() instead: Thank you Peter, that was the missi

Re: delegate functions to member

2010-08-10 Thread Peter Otten
Ulrich Eckhardt wrote: > Peter Otten wrote: >> Use getattr() >> > class W(object): >> ... def __init__(self, wrapped): self._wrapped = wrapped >> ... def __getattr__(self, name): >> ... return getattr(self._wrapped, name) >> ... > > I thought there was something like this

Re: delegate functions to member

2010-08-10 Thread Ulrich Eckhardt
Peter Otten wrote: > Use getattr() > class W(object): > ... def __init__(self, wrapped): self._wrapped = wrapped > ... def __getattr__(self, name): > ... return getattr(self._wrapped, name) > ... I thought there was something like this, thanks! :) When I read this, I tho

Re: delegate functions to member

2010-08-10 Thread Chris Rebert
On Tue, Aug 10, 2010 at 2:01 AM, Ulrich Eckhardt wrote: > Hi! > > I have an extension module (a plugin written with Boost.Python) and around > that a wrapper class that adapts a few things. Since the module is a > plugin, there are multiple implementations of this. What I'm currently > doing is th

Re: delegate functions to member

2010-08-10 Thread Peter Otten
Ulrich Eckhardt wrote: > Hi! > > I have an extension module (a plugin written with Boost.Python) and around > that a wrapper class that adapts a few things. Since the module is a > plugin, there are multiple implementations of this. What I'm currently > doing is this: > > plugin = __import__(pl

delegate functions to member

2010-08-10 Thread Ulrich Eckhardt
Hi! I have an extension module (a plugin written with Boost.Python) and around that a wrapper class that adapts a few things. Since the module is a plugin, there are multiple implementations of this. What I'm currently doing is this: plugin = __import__(plugin_name) class PluginWrapper(plugin.