I usually go with + only to find out that dict was something special
here. ;-)
Then, I use .update only to find out, that it's in-place and I need to
join more than two.
Then, I use some sort of dict comprehension or the dict constructor etc.
Naively, I would say + is what comes to mind easily. :D
Then, even sum(my_dicts) would work. ;-)
on-topic: Multiple arguments to dict(*my_dicts) just complements the
alternative {**...} comprehension. So, it seems legit. +1
On 12.04.2018 21:32, Andrés Delfino wrote:
There's a long thread about the subject:
https://mail.python.org/pipermail/python-ideas/2015-February/031748.html
I suggest to avoid the matter altogether :)
On Thu, Apr 12, 2018 at 4:15 PM, Mike Miller
<python-id...@mgmiller.net <mailto:python-id...@mgmiller.net>> wrote:
While we're on the subject, I've tried to add dicts a few times
over the years to get a new one but it doesn't work:
d3 = d1 + d2 # TypeError
Thinking a bit, set union is probably a better analogue, but it
doesn't work either:
d3 = d1 | d2 # TypeError
Where the last value of any duplicate keys should win.
-Mike
On 2018-04-12 06:46, Andrés Delfino wrote:
Extending the original idea, IMHO it would make sense for the
dict constructor to create a new dictionary not only from
several mappings, but mixing mappings and iterables too.
Consider this example:
x = [(1, 'one')]
y = {2: 'two'}
Now: {**dict(x), **y}
Proposed: dict(x, y)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org <mailto:Python-ideas@python.org>
https://mail.python.org/mailman/listinfo/python-ideas
<https://mail.python.org/mailman/listinfo/python-ideas>
Code of Conduct: http://python.org/psf/codeofconduct/
<http://python.org/psf/codeofconduct/>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/