In article <[EMAIL PROTECTED]>, David Isaac <[EMAIL PROTECTED]> wrote: >"Ziga Seilnacht" <[EMAIL PROTECTED]> wrote: >> >> If you want to restrict attribute asignment, you should use the >> __setattr__ special method, see: >> http://docs.python.org/ref/attribute-access.html > >That "should" is what I am asking about. If I understand, >in the simplest case, you want me to say something like > def __setattr__(self,name,value): > if name in myattrlist: > object.__setattr__(self,name,value) > else: > raise AttributeError >instead just saying > __slots__ = myattrlist >I understand that this *is* the prevailing advice. But why?
Because __slots__ breaks with inheritance. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "Look, it's your affair if you want to play with five people, but don't go calling it doubles." --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list