Re: extending class static members and inheritance

2013-04-02 Thread Arnaud Delobelle
On 2 April 2013 14:27, Fabian PyDEV wrote: > Hi All, > > I have a question. > > Let says I have the following two classes: > > class Base(object): > __mylist__ = ["value1", "value2"] > > def somemethod(self): > pass > > > class Derived(Base): > __mylist__ =

Re: extending class static members and inheritance

2013-04-02 Thread Dave Angel
On 04/02/2013 09:27 AM, Fabian PyDEV wrote: Hi All, I have a question. Let says I have the following two classes: class Base(object): __mylist__ = ["value1", "value2"] def somemethod(self): pass class Derived(Base): __mylist__ = ["value3", "value4"]

extending class static members and inheritance

2013-04-02 Thread Fabian PyDEV
Hi All, I have a question. Let says I have the following two classes: class Base(object): __mylist__ = ["value1", "value2"] def somemethod(self): pass class Derived(Base): __mylist__ = ["value3", "value4"] def anothermethod(self):

Re: extending class

2011-09-23 Thread Steven D'Aprano
Andrea Crotti wrote: > I wanted to add a couple of parameters to a class from a given library > (paste-script), but without changing the original code. > So I thought, I create a wrapper class which adds what I need, and then > dispatch all the calls to the super class. You don't need to use a wr

Re: extending class

2011-09-23 Thread Andrea Crotti
Jean-Michel Pichavant writes: > Did you consider subclassing your Var class ? This is how you extend a > class behavior in OOP. > > class PSIVar(var): >def __init__(self, name, desc, other=None, fun=None): >var.__init__(self, name, desc) >if other is not None: >sel

Re: extending class

2011-09-23 Thread Jean-Michel Pichavant
Andrea Crotti wrote: On 09/23/2011 10:31 AM, Peter Otten wrote: Inside __getattribute__() you ask for self.first_var which triggers another __getattribute__() call that once again trys to determine the first_var attribute before it returns... Try using __getattr__() instead which is only tri

Re: extending class

2011-09-23 Thread Andrea Crotti
On 09/23/2011 10:31 AM, Peter Otten wrote: Inside __getattribute__() you ask for self.first_var which triggers another __getattribute__() call that once again trys to determine the first_var attribute before it returns... Try using __getattr__() instead which is only triggered for non-existent

Re: extending class

2011-09-23 Thread Peter Otten
Andrea Crotti wrote: > I wanted to add a couple of parameters to a class from a given library > (paste-script), but without changing the original code. > So I thought, I create a wrapper class which adds what I need, and then > dispatch all the calls to the super class. > > My following attempt g

extending class

2011-09-23 Thread Andrea Crotti
I wanted to add a couple of parameters to a class from a given library (paste-script), but without changing the original code. So I thought, I create a wrapper class which adds what I need, and then dispatch all the calls to the super class. My following attempt gives, however, a recursion erro