[Python-ideas] PEP: Dict addition and subtraction

Inada Naoki songofacandy at gmail.com
Tue Mar 5 05:36:31 EST 2019


On Tue, Mar 5, 2019 at 7:26 PM Steven D'Aprano <steve at pearwood.info> wrote:
>
> On Sat, Mar 02, 2019 at 01:47:37AM +0900, INADA Naoki wrote:
> > > If the keys are not strings, it currently works in CPython, but it may not work with other implementations, or future versions of CPython[2].
> >
> > I don't think so.  https://bugs.python.org/issue35105 and
> > https://mail.python.org/pipermail/python-dev/2018-October/155435.html
> > are about kwargs.  I think non string keys are allowed for {**d1,
> > **d2} by language.
>
> Is this documented somewhere?
>

It is not explicitly documented.  But unlike keyword argument,
dict display supported non-string keys from very old.

I believe {3: 4} is supported by Python language, not CPython
implementation behavior.

https://docs.python.org/3/reference/expressions.html#grammar-token-dict-display

> Or is there a pronouncement somewhere that it is definitely expected to
> work in any language calling itself Python?
>
>
> Thanks,
>
>
>
> --
> Steven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
Inada Naoki  <songofacandy at gmail.com>


More information about the Python-ideas mailing list