[Python-Dev] __xxxattr__ caching semantic
Samuele Pedroni
Samuele Pedroni <pedroni@inf.ethz.ch>
Fri, 1 Jun 2001 14:49:11 +0200 (MET DST)
Hi.
What is the intendend semantic wrt to __xxxattr__ caching:
class X:
pass
def cga(self,name):
print name
def iga(name):
print name
x=X()
x.__dict__['__getattr__'] = iga # 1.
x.__getattr__ = iga # 2.
X.__dict__['__getattr__'] = cga # 3.
X.__getattr__ = cga # 4.
x.a
for the manual
http://www.python.org/doc/current/ref/customization.html
with all the variants x.a should fail, they should have
no effect. In practice 4. work.
Is that an implementation manual mismatch, is this indented, is there
code around using 4. ?
I'm asking this because jython has differences/bugs in this respect?
I imagine that 1.-4. should work for all other __magic__ methods
(this should be fixed in jython for some methods),
OTOH jython has such a restriction on __del__ too, and this one cannot
be removed (is not simply a matter of caching/non caching).
regards, Samuele Pedroni.