Notice that {'x':1} and dict(x=1) are different beasts: The first one 
compiles directly to BUILD_MAP. The second one loads a reference to 
'dict' from globals() and calls the constructor. The two are not the 
same.<br>
<br><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/15 Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</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 15/11/12 05:54, Mark Adam wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Merging of two dicts is done with dict.update.   How do you do it on<br>
initialization?  This doesn't make sense.<br>
</blockquote>
<br></div>
Frequently.<br>
<br>
my_prefs = dict(default_prefs, setting=True, another_setting=False)<br>
<br>
<br>
Notice that I'm not merging one dict into another, but merging two dicts<br>
into a third.<br>
<br>
(Well, technically, one of the two comes from keyword arguments rather<br>
than an actual dict, but the principle is the same.)<br>
<br>
The Python 1.5 alternative was:<br>
<br>
my_prefs = {}<br>
my_prefs.update(default_prefs)<br>
my_prefs['setting'] = True<br>
my_prefs['another_setting'] = False<br>
<br>
<br>
Blah, I'm so glad I don't have to write Python 1.5 code any more. Even<br>
using copy only saves a line:<br>
<br>
my_prefs = default_prefs.copy()<br>
my_prefs['setting'] = True<br>
my_prefs['another_setting'] = False<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
<br>
-- <br>
Steven</font></span><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="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/lukas.lueg%40gmail.com" target="_blank">http://mail.python.org/<u></u>mailman/options/python-dev/<u></u>lukas.lueg%40gmail.com</a><br>
</div></div></blockquote></div><br></div>