<p dir="ltr"><br>
On 29 Jul 2014 08:22, "Alexander Heger" <<a href="mailto:python@2sn.net">python@2sn.net</a>> wrote:</p>
<p dir="ltr">><br>
> My point is to make the dict() data structure more easy to use for<br>
> most users and use cases. Especially novices.<br>
> This is what adds power to the language. Not that you can do things<br>
> (Turing machines can) but that you can do them easily and naturally.</p>
<p dir="ltr">But why is dict merging into a *new* dict something that needs to be done as a single expression? What's the problem with spelling out "to merge two dicts into a new, first make a dict, then merge in the other one":</p>
<p dir="ltr"> x = dict(a)<br>
x.update(b)</p>
<p dir="ltr">That's the real competitor here, not the more cryptic "x = dict(a, **b)"</p>
<p dir="ltr">You can even use it as an example of factoring out a helper function:</p>
<p dir="ltr"> def copy_and_update(a, *args):<br>
x = dict(a)<br>
for arg in args:<br>
x.update(arg)<br>
return x</p>
<p dir="ltr">My personal experience suggests that's a rare enough use case that it's fine to leave it as a trivial helper function that people can write if they need it. The teaching example isn't compelling, since in the teaching case, spelling out the steps is going to be necessary anyway to explain what the function or method call is actually doing.</p>
<p dir="ltr">Cheers,<br>
Nick.<br></p>
<p dir="ltr">> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a><br>
</p>