You went from "not what you want for numerical work" to "generalizing that concept comes back to bite you". I don't think you can make that step.
I do non-numeric scientific computing. (Meaning, I touch numpy about once a year.) My own code does things like
[0] * N # could be replaced with something like numpy.zeros()
[QUERIES_FPS] * 501
to_trans = [None]*256 # constructing a 256 byte translation table
# (I could use zeros(), but used None to force an exception
# if I missed a cell)
self.assertEqual(self._get_records(simple.record*2),
[(simple.title, simple.record)]*2)
# I parse a string containing two records and test I should
# be able to get the (id, record) for each one
["--queries", SIMPLE_FPS, "-k", "3", "--threshold",
"0.8"] + self.extra_args # Construct a command-line from 2 lists
These idioms also exist in the standard library, like:
So while I think you are correct, in that "+" causes confusion across multiple domains with different meaning for "+", I think the moral is that operating overloading is intrinsically confusing and should be avoided for all but the clearest of use cases.
There is no best generalization to "+". For example, if you pick the vector math meaning, then regular Python would have that:
["A", "B"] + ["C", "D"] == ["AC", "BD"]
which has its own logic, but is likely not what most people who haven't done vector math expect.
I do non-numeric scientific computing. (Meaning, I touch numpy about once a year.) My own code does things like
These idioms also exist in the standard library, like: So while I think you are correct, in that "+" causes confusion across multiple domains with different meaning for "+", I think the moral is that operating overloading is intrinsically confusing and should be avoided for all but the clearest of use cases.There is no best generalization to "+". For example, if you pick the vector math meaning, then regular Python would have that:
which has its own logic, but is likely not what most people who haven't done vector math expect.