A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-September/028978.html below:

[Python-Dev] buitlins instance have modifiable __class__?

[Python-Dev] buitlins instance have modifiable __class__? [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.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4