[Python-Dev] (no subject) (original) (raw)

Ian Lee ianlee1521 at gmail.com
Wed Feb 11 06:35:22 CET 2015


+1 for adding "+" or "|" operator for merging dicts. To me this operation:

{'x': 1, 'y': 2} + {'z': 3} {'x': 1, 'y': 2, 'z': 3}

Is very clear. The only potentially non obvious case I can see then is when there are duplicate keys, in which case the syntax could just be defined that last setter wins, e.g.:

{'x': 1, 'y': 2} + {'x': 3} {'x': 3, 'y': 2}

Which is analogous to the example:

new_dict = dict1.copy() new_dict.update(dict2)

~ Ian Lee

On Tue, Feb 10, 2015 at 12:11 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:

On 10.02.15 04:06, Ethan Furman wrote:

return func(*(args + fargs), **{**keywords, **fkeywords})

We don't use [*args, *fargs] for concatenating lists, but args + fargs. Why not use "+" or "|" operators for merging dicts?


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ ianlee1521%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150210/80f139cd/attachment.html>



More information about the Python-Dev mailing list