[Python-ideas] Why operators are useful
Antoine Pitrou
solipsis at pitrou.net
Mon Mar 18 10:12:52 EDT 2019
On Mon, 18 Mar 2019 14:06:53 +0000
Rhodri James <rhodri at kynesim.co.uk> wrote:
> On 16/03/2019 12:01, Gustavo Carneiro wrote:
> > Already been said, but might have been forgotten, but the new proposed
> > syntax:
> >
> > new = a + b
> >
> > has to compete with the already existing syntax:
> >
> > new = {**a, **b}
> >
>
> That's easy. Whether it's spelt with "+" or "|" or pretty much anything
> else, the operator version is clearer and cleaner. "{**a, **b}" is a
> combination of operators and literal (display) syntax, and following
> Guido's reasoning that makes it inherently harder to interpret. It's
> also ugly IMHO, but that's me.
The question is whether it's too hard or ugly for the use cases. In
other words: where are the use cases where it's frequent enough to
merge dicts that a nicer syntax is required?
(also, don't forget you can still use the copy() + update() method)
Regards
Antoine.
More information about the Python-ideas
mailing list