On Fri, Oct 18, 2019 at 2:49 PM Chris Angelico <rosuav@gmail.com> wrote:
On Fri, Oct 18, 2019 at 11:41 PM Richard Musil <risa2000x@gmail.com> wrote:
I know this has been somewhat addressed in PEP, but I simply cannot see,
how adding another ambiguity to the '+' symbol, can be better, because the "familiarity" of '+' (which seems to me being an argument in the PEP) just hides the fundamental differences between this '+' and the other ones (arithmetic, or concatenation).
Adding a time delta to a datetime isn't quite the same as adding two numbers. Adding two strings is even more different. Adding two tuples, different again. Yet they are all "adding" in a logical way. Checking if an integer is in a list isn't the same as checking if one is in a dict, and checking if a substring is in a larger string is even more different, yet, again, they are all testing for "containment". This is polymorphism. This is the normal way that Python works. What "fundamental differences" are there to be hidden? Are they not simply the nature of addition as defined by a dictionary?
I have no problem with any example you mentioned above, yet I consider proposed meaning for '+' symbol in this PEP context fundamentally different from either "arithmetic" or "concatenation" meaning, used in the previous examples, because it does not only adds, but also changes the values. Technically we can call set union also an "add" operation, yet we use different semantics to express it, for exactly the same reason, it is not "arithmetic" nor, "concatenation", but something different. Richard