Re:Dictionary union (PEP 584) is merged
by fyp on Tuesday February 25, 2020 @06:04PM
(#22418498)
is very natural if you also write javascript where their spread operator looks like:
[ Parent
| on HN ]
Re:Dictionary union (PEP 584) is merged
by whalesalad on Tuesday February 25, 2020 @06:56PM
(#22418857)
This is reason enough to upgrade from Python 2.7 if you are still on it. I use this convenience almost daily.
No it isn’t.
Re:Dictionary union (PEP 584) is merged
by tempay on Wednesday February 26, 2020 @01:22AM
(#22420787)
One of the issues with Python 3 is that there isn’t really one killer feature, it’s countless little ones. Many believe 3.6 was the first release where they added up to enough of a benefit (though f-strings are a big help for many projects).
Regardless it no longer matters, the Python 2 ecosystem is now rotting as packages drop support. Every week I have to make one or two hot fixes somewhere to forcibly pin to an old version to fix something.
Re:Dictionary union (PEP 584) is merged
by edudobay on Wednesday February 26, 2020 @07:40AM
(#22422392)
For me, proper handling and distinction of Unicode vs. binary data was a game changer. I don't know if that's related to my first language being non-English, but I remember it being really important to me and a strong reason why I made the switch years ago.
Re:Dictionary union (PEP 584) is merged
by heavenlyblue on Wednesday February 26, 2020 @09:31AM
(#22423188)
I used to work for a huge SEM business working with keywords in all languages of the world. No-brainer.
Re:Dictionary union (PEP 584) is merged
by martopix on Wednesday February 26, 2020 @06:07AM
(#22422021)
I would definitely mention integer division as a massive change in py3 too. In my field, the @ multiplication operator is also useful.
Re:Dictionary union (PEP 584) is merged
by teddyh on Wednesday February 26, 2020 @07:45AM
(#22422417)
> I would definitely mention integer division as a massive change in py3 too.
To be fair, you can get that in Python 2 too:
from __future__ import division
Re:Dictionary union (PEP 584) is merged
by modal-soul on Tuesday February 25, 2020 @11:06PM
(#22420192)
Even more natural if you write Ruby, which uses an identical syntax.
So PEP 584 is a JavaScript inspired feature request?
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.