Adding properties to an instance

dg.google.groups at thesamovar.net dg.google.groups at thesamovar.net
Thu Feb 7 06:03:57 EST 2008


> As a side note: the naming symetry between __getattr__ and __setattr__
> is a gotcha, since __setattr__ is mostly symetric to __getattribute__ -
> IOW, customizing __setattr__ is a bit tricky. The naive approach, ie:

Ah I see - so __setattr__ is called immediately whereas __getattr__ is
only called if the other methods fail. Does this mean that __setattr__
incurs the same performance penalty that overriding __getattribute__
would? Possibly I can live with this because I think that most of what
I'm doing is getting attributes, or modifying mutable ones, rather
than setting them.

--
Dan



More information about the Python-list mailing list