replacing instance __setattr__
Bernhard Herzog
bh at intevation.de
Thu Jul 4 12:36:02 EDT 2002
Jonathan Hogg <jonathan at onegoodidea.com> writes:
> There's only one special case that I know of and that's the special
> attribute methods, which are different for the reason I posted before: they
> *are* the mechanism that implements the lookup order.
I'm not sure about the new style classes as I haven't had the time to
really look at them yet, but for old style classes that's not quite
true.
For instance, __getattr__ does *not* define how attributes are looked
up. It's only called by the interpreter when the normal attribute lookup
fails.
For __setattr__ and __delattr__ it's different. They do indeed override
the normal set/del attribute operation. Otherwise they wouldn't be
useful after all.
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://www.mapit.de/
More information about the Python-list
mailing list