derived classes and __getattr__

Fredrik Lundh fredrik at pythonware.com
Fri Sep 5 10:55:56 CEST 2008


Alexandru Mos,oi wrote:

> i'm facing the following problem:
> 
> class Base(object):
>   def __getattr__(self, attr): return lambda x: attr + '_' + x
> 
> def dec(callable):
>   return lambda *args: 'dec_' + callable(*args)
> 
> class Derived(Base):
>    what_so_ever = dec(Base.what_so_ever) # wrong, base doesn't have
> what_so_ever
>    mumu = dec(Base.mumu)                          # wrong, base
> doesn't have mumu
> 
> any idea how to do this?

ever thought of using Python to write Python programs?

</F>




More information about the Python-list mailing list