derived classes and __getattr__

Alexandru Moșoi alexandru.mosoi at gmail.com
Fri Sep 5 04:17:32 EDT 2008


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?



More information about the Python-list mailing list