[Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

Inada Naoki songofacandy at gmail.com
Tue Mar 5 06:02:17 EST 2019


On Tue, Mar 5, 2019 at 7:59 PM Steven D'Aprano <steve at pearwood.info> wrote:
>
> On Tue, Mar 05, 2019 at 06:04:40PM +0900, INADA Naoki wrote:
> [...]
> > One obvious merit of d.merge(...) is it returns same type of d.
> > `type(d1)(d1, d2)` looks ugly.
> >
> > But people just want dict instead of some subtype of dict.
> > This merit is not so important.
>
> Not to me! It *is* important to me.

I'm sorry, I missed "most".

>
> I want builtins to honour their subclasses. It is probably too late to
> change existing behaviour, but my proposal specifies that subclasses are
> honoured.
>

Then my proposal `d1.merge(d2)` is much better than alternative
dict(d1, d2) for you.

-- 
Inada Naoki  <songofacandy at gmail.com>


More information about the Python-ideas mailing list