Re:Dictionary union (PEP 584) is merged
by devy on Tuesday February 25, 2020 @10:03PM
(#22419895)
So PEP 584 is a JavaScript inspired feature request?
[ Parent
| on HN ]
Re:Dictionary union (PEP 584) is merged
by beanpup_py on Tuesday February 25, 2020 @10:24PM
(#22420006)
No, it adds a new merge (|) and update (|=) operator to avoid using
{**d1, **d2}
because it apparently looks ugly[1].
Re:Dictionary union (PEP 584) is merged
by privateSFacct on Wednesday February 26, 2020 @12:51AM
(#22420650)
And in doing so creates multiple ways to do the same thing which is SUPER SUPER annoying.
There has been a recent effort to add all these new operators that don't actually let you do anything you couldn't but now you can confuse everyone by doing it in other ways.
Re:Dictionary union (PEP 584) is merged
by kzrdude on Wednesday February 26, 2020 @03:55AM
(#22421485)
Python doesn't use formal interfaces. This makes dicts implement unions in a duck typeable way - the operators.
Re:Dictionary union (PEP 584) is merged
by py3001 on Wednesday February 26, 2020 @04:44AM
(#22421676)
instead of actually useful features like dict deconstruction
Re:Dictionary union (PEP 584) is merged
by banannaise on Thursday February 27, 2020 @01:05PM
(#22435874)
The bigger reasons are discoverability (as noted in the section you linked) and the ever-vague notion of Pythonic-ness.
{d1, d2} is not intuitive to a primarily-Python developer, and looks nothing like typical Python. The dict unpacking operator it uses is almost never seen outside function arguments.