Default attribute in base class precludes delegation

Bengt Richter bokr at oz.net
Fri Dec 19 07:50:04 CET 2003


On 19 Dec 2003 06:38:59 GMT, bokr at oz.net (Bengt Richter) wrote:
[...]
>If you change the Derived class in your original post (and above) to:
>
>class Derived(object,Base):
>     def __init__(self, worker):
>         self.worker = worker
>
>     def __getattribute__(self, name):
>         return getattr(object.__getattribute__(self, '__dict__')['worker'], name)
          # or a little more concisely seems to work too:
          return getattr(object.__getattribute__(self, 'worker'), name)
>
>
>I think it will get all the attributes, for better or worse, from worker (and the output
>you wanted). You'll have to sort out what names you might want to deal with differently, though ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list