On Wed, Feb 11, 2015 at 12:35 AM, Ian Lee <ianlee1...@gmail.com> wrote:

> +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)
>
>
> Well looking at just list
a + b yields new list
a += b yields modified a
then there is also .extend in list. etc.

so do we want to follow list's footstep? I like + because + is more natural
to read. Maybe this needs to be a separate thread. I am actually amazed to
remember dict + dict is not possible... there must be a reason
(performance??) for this...
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to