<div dir="ltr"><div><div>Should'nt the key'ing behaviour be controlled by the type of the key instead of the type of the container?<br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/10 MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 10/09/2013 20:08, Paul Moore wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10 September 2013 19:31, Antoine Pitrou <<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think it would be a flaw to have this detail implementation-defined.<br>
This would be like saying that it is implementation-defined which<br>
of A,B,C is returned from "A and B and C" if all are true.<br>
</blockquote>
<br>
Ok, it seems everyone (except me :-)) agrees that it should return the<br>
first key value, so that's how it will be.<br>
</blockquote>
<br>
If you retain the first key value, it's easy enough for the<br>
application to implement "retain the last" semantics:<br>
<br>
try:<br>
     del d[k]<br>
finally:<br>
     d[k] = v<br>
<br>
</blockquote></div>
That would raise a KeyError is the key was missing. A better way is:<br>
<br>
d.pop(k, None)<div class="im"><br>
d[k] = v<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you provide "retain the last", I can't see any obvious way of<br>
implementing "retain the first" in application code without in effect<br>
reimplementing the class.<br>
<br>
</blockquote></div>
"Retain the first" does feel more natural to me.<div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/lukas.lueg%40gmail.com" target="_blank">https://mail.python.org/<u></u>mailman/options/python-dev/<u></u>lukas.lueg%40gmail.com</a><br>
</div></div></blockquote></div><br></div>