Re: derived classes and __getattr__

2008-09-05 Thread Bruno Desthuilliers
Alexandru Mosoi a écrit : (snip) i somehow fixed the problem using: def __getattr__(self, attr): return functools.partial(Base.__metaclass__.__getattr__(self.__class__, attr), self) however this looks ugly enough to look for another solution. i still have one more question: why do I h

Re: derived classes and __getattr__

2008-09-05 Thread Alexandru Mosoi
On Sep 5, 1:13 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Alexandru  Mosoi wrote: > > On Sep 5, 11:47 am, Peter Otten <[EMAIL PROTECTED]> wrote: > >> Alexandru Moșoi wrote: > >> > i'm facing the following problem: > > >> > class Base(object): > >> > def __getattr__(self, attr): return lambda x: a

Re: derived classes and __getattr__

2008-09-05 Thread Michele Simionato
On Sep 5, 11:46 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > I have another small problem. now, > d.third('blah') doesn't work because instance d doesn't have 'third' > attribute. I was expecting derived class to inherit the metaclass as > well, but it didn't. Yep, it is explained here: http

Re: derived classes and __getattr__

2008-09-05 Thread Peter Otten
Alexandru Mosoi wrote: > On Sep 5, 11:47 am, Peter Otten <[EMAIL PROTECTED]> wrote: >> Alexandru Moș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: '

Re: derived classes and __getattr__

2008-09-05 Thread Alexandru Mosoi
On Sep 5, 11:47 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Alexandru Moș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) > > > c

Re: derived classes and __getattr__

2008-09-05 Thread Fredrik Lundh
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 h

Re: derived classes and __getattr__

2008-09-05 Thread Peter Otten
Alexandru Moș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) # wron

derived classes and __getattr__

2008-09-05 Thread Alexandru Moșoi
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 =