In <[EMAIL PROTECTED]>, Frank Millman
wrote:

> On Jun 11, 12:21 pm, Steven D'Aprano
> <[EMAIL PROTECTED]> wrote:
>> > I use __slots__ to catch any invalid attributes, otherwise I would get
>> > a 'maximum recursion depth exceeded' error.
>>
>> That's the wrong solution to that problem. To avoid that problem,
>> __getattr__ should write directly to self.__dict__.
>>
> 
> Are you saying that instead of
> 
>     self.z = self.x * self.y
>     return getattr(self.name)
> 
> I should have
> 
>     self.__dict__['z'] = self.x * self.y
>     return self.__dict__[name]
> 
> I tried that, but I get AttributeError: 'A' object has no attribute
> '__dict__'.
That's because you used `__slots__`.  One of the drawbacks of `__slots__`.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to