Steven D'Aprano writes:

 > If you learn that + means update, then everything follows from
 > that.

"+" doesn't mean "update", though.  It means "accumulate".

Consider sets.  Except in situations where we have a very limited
vocabulary for operators, such as ASCII-origin programming languages,
we avoid using "+" to denote set union.  In fact, in set theory, we go
through a whole bunch of rigamarole to *define* numerical "+" as the
*disjoint* union of finite numbers, each a canonical set of sets.

Or consider analysis.  Addition of functions (complex-valued or
real-valued) is defined pointwise, as the sum of the values of the
functions at each point.  In general, vectors, matrices, and so on.

I'm not against having an operator for updating dicts, but "+" is not
it.  "|" is fine, though.

I'm unlikely to use the operator myself.  In my experience I almost
always want to do other stuff (type- or range-checking, mostly,
sometimes collecting "profiling" statistics) in the method, and I
prefer explict method invocation for such side effects.  But I don't
want to be reading other people's code and needing to remember that
"+" is a pointwise replacement, not accumulation.

Steve

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VMIZVFQJDYPX73ELUCXTKBPCLMTADBNP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to