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 thought "OK, now I only have check first if the
attribute can be looked up in 'self' first", but even that isn't the case.
I tried it and added another function to class W above, which I can call
just as if it was defined in _wrapped, so obviously (?) the __getattr__
lookup isn't done there.

So, short follow-up question: Why does this work?

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to