"Ian Kelly" wrote in message
news:calwzidkp3ls4s-zi3ax6no-68kw4_xdozvwa-cj+oz+apqr...@mail.gmail.com...
On Mon, Feb 5, 2018 at 12:35 AM, Frank Millman <fr...@chagford.com> wrote:
> So I have 2 questions -
>
> 1. Is there any particular reason why '|' is not supported?
'|' is the set union operation, roughly equivalent to the set.union
method. Dicts don't have a union operation. If they did, and the same
key were found in both sets, what would be the value of that key in
the union?
> 2. Is there a better way to do what I want?
The dict.items() view is explicitly set-like and can be unioned, so
you can do this:
py> dict(d1.items() | d2.items())
Excellent explanation, and excellent solution!
Thanks very much.
Frank
--
https://mail.python.org/mailman/listinfo/python-list