Hello,
Great.
Because I don't program in any other language except Python, I can't
make the PR (with the C code).
Maybe someone who program in C can help?
Best regards,
João Matos
On 27-02-2019 18:48, Guido van Rossum
wrote:
On Wed, Feb 27, 2019 at
10:42 AM Michael Selik < m...@selik.org> wrote:
I dislike the
asymmetry with sets:
> {1} | {2}
{1, 2}
To me it makes sense that if + works for dict then
it should for set too.
/ Anders
> On 27 Feb 2019, at 17:25, João Matos <jcrma...@gmail.com>
wrote:
>
> Hello,
>
> 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
The dict subclass collections.Counter overrides the
update method for adding values instead of overwriting
values.
Counter also uses +/__add__ for
a similar behavior.
>>> c = Counter(a=3, b=1)
>>> d = Counter(a=1, b=2)
>>> c + d # add two counters
together: c[x] + d[x]
Counter({'a': 4, 'b': 3})
At first I worried that changing base dict would
cause confusion for the subclass, but Counter seems
to share the idea that update and + are synonyms.
Great, this sounds like a good argument for + over |. The
other argument is that | for sets *is* symmetrical, while +
is used for other collections where it's not symmetrical. So
it sounds like + is a winner here.
--
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
|
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/