extending class

Andrea Crotti andrea.crotti.0 at gmail.com
Fri Sep 23 05:35:49 EDT 2011


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
> attributes
>
> def __getattr__(self, name):
>      return getattr(self.first_var, name)
>
> or check for the attributes you don't want to delegate explicitly:
>
> def __getattribute__(self, name):
>      if name == "first_var":
>          return super(PSIVar, self).__getattribute__(name)
>

Right thanks a lot it works perfectly.
I don't like too much, however, to mess around in this way, maybe it's 
better if I just fork the project
and patch the original code.

In this way maybe I can also contribute to it with patches (if they are 
accepted)...



More information about the Python-list mailing list