Re: Use of lambda functions in OOP, any alternative?

2006-05-26 Thread Maric Michaud
Le Mercredi 24 Mai 2006 22:37, Scott David Daniels a écrit : >      class Base(object): >          def __init__(self, attr): >              self._attr = attr >          def getattr(self): >              return self._attr >          def attr(self): >              return self.getattr() >          att

Re: Use of lambda functions in OOP, any alternative?

2006-05-25 Thread Pablo
Oh! Thanx! Great! this is what i was looking for! :) Scott David Daniels ha escrito: > Pablo wrote: > > > Second solution: This is what i want, but... > > > > class Base(object): > > def __init__(self, attr): > > self._attr = attr > > def getattr(self): > > return self._at

Re: Use of lambda functions in OOP, any alternative?

2006-05-24 Thread Scott David Daniels
Pablo wrote: > Second solution: This is what i want, but... > > class Base(object): > def __init__(self, attr): > self._attr = attr > def getattr(self): > return self._attr > attr = property(fget=lambda self: self.getattr()) > > class Derived(Base): > def getattr(

Re: Use of lambda functions in OOP, any alternative?

2006-05-23 Thread Pablo
The reason i would like a different approach to the lambda function is just a question of personal taste... i dont really like it. thanx! -- http://mail.python.org/mailman/listinfo/python-list

Re: Use of lambda functions in OOP, any alternative?

2006-05-23 Thread Maric Michaud
Le Mardi 23 Mai 2006 15:55, Pablo a écrit : > Question: Isn't there an *alternative* way to do it without the lambda > function? No, it's good, why shouldn't you use a lambda function ? Note you can do something like this : class _virtualgetter : def __init__(self, name) : self._n =name

Re: Use of lambda functions in OOP, any alternative?

2006-05-23 Thread Pablo
Pablo ha escrito: > Hello all, sorry if this is a faq... > > Problem: The intended effect is to override the method 'getattr' in a > way that i dont need to override the property explicitly too. > > class Base(object): > def __init__(self, attr): > self._attr = attr > def getattr(s

Use of lambda functions in OOP, any alternative?

2006-05-23 Thread Pablo
Hello all, sorry if this is a faq... Problem: The intended effect is to override the method 'getattr' in a way that i dont need to override the property explicitly too. class Base(object): def __init__(self, attr): self._attr = attr def getattr(self): return self._attr