[Python-Dev] buitlins instance have modifiable __class__?
Samuele Pedroni
pedronis@bluewin.ch
Fri, 27 Sep 2002 22:40:30 +0200
question on bultin types (under 2.2):
>>> d={}
>>> class ndict(dict):
... __slots__ = ()
... def __getitem__(self,k):
... print "__getitem__"
... return dict.__getitem__(self,k)
...
>>> d.items()
[]
>>> d['a']=3
>>> d.__class__=ndict
is intended to work?
it seems it does, but is that the intention?
>>> d['a']
__getitem__
3
[
>>> exec "print a" in d
3
Ok, that is the non cooperative behavior I already know about. ]
Thanks.