A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-June/035971.html below:

[Python-Dev] Mundane dict __setitem__...

[Python-Dev] Mundane dict __setitem__...Samuele Pedroni pedronis@bluewin.ch
Tue, 03 Jun 2003 14:22:15 +0200
At 08:09 03.06.2003 -0400, David Abrahams wrote:

>I am about to write some code which relies on the following:
>
>     x = (1,2,3)
>     y = (1,2,3)
>     d = {}
>     d[x] = 1
>     d[y] = 1
>     assert d.keys()[0] is y
>
>In other words, when you do d[k] = v it replaces both v *and* k in the
>dict.  I couldn't find it documented anywhere but the source.  I
>submitted a doc patch which enshrines that behavior, but since Guido
>doesn't always know what's in the doc I wanted to make sure it was
>considered reasonable.
>
>Anyone want to tell me it's a bad idea?  It seems like the more useful
>of the two possible behaviors to me.


that's not the case with Jython, i.e. the assert will fail in Jython.

Dicts are equality not identity dicts so both behavior, as I see it, are 
fine. In the end what happens with the fragment is unspecified.

regards. 




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