On Wed, Feb 27, 2019 at 09:05:20AM -0800, Guido van Rossum <[email protected]> 
wrote:
> On Wed, Feb 27, 2019 at 8:50 AM Rhodri James <[email protected]> wrote:
> 
> > On 27/02/2019 16:25, Jo??o Matos wrote:
> > > I would like to propose that instead of using this (applies to Py3.5 and
> > upwards)
> > > dict_a = {**dict_a, **dict_b}
> > >
> > > we could use
> > > dict_a = dict_a + dict_b
> > >
> > > or even better
> > > dict_a += dict_b
> >
> > While I don't object to the idea of concatenating dictionaries, I feel
> > obliged to point out that this last is currently spelled
> > dict_a.update(dict_b)
> >
> 
> This is likely to be controversial. But I like the idea. After all, we have
> `list.extend(x)` ~~ `list += x`. The key conundrum that needs to be solved
> is what to do for `d1 + d2` when there are overlapping keys. I propose to
> make d2 win in this case, which is what happens in `d1.update(d2)` anyways.
> If you want it the other way, simply write `d2 + d1`.

That is, ``d1 + d2`` is::

    d = d1.copy()
    d.update(d2)
    return d

> -- 
> --Guido van Rossum (python.org/~guido)

Oleg.
-- 
    Oleg Broytman            https://phdru.name/            [email protected]
           Programmers don't die, they just GOSUB without RETURN.
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to