On Sun, Feb 3, 2019 at 3:16 PM Ronald Oussoren email@example.com wrote:
The @ operator is meant for matrix multiplication (see PEP 465) and is already used for that in NumPy. IMHO just that is a good enough reason for not using @ as an elementwise application operator (ignoring if having an such an operator is a good idea in the first place).
Co-opting operators is pretty common in Python. For example, the `.__div__()` operator spelled '/' is most often used for some kind of numeric division. Some variations on that, for example vectorized in NumPy. And different numeric types operate a bit differently. The name of the magic method obvious suggests division.
And yet, in the standard library we have pathlib which we can use like this (from the module documentation):
p = Path('/etc')>>> q = p / 'init.d' / 'reboot'
That use is reasonable and iconic, even if it is nothing like division.
The `.__mod__()` operator spelled '%' means something very different in relation to a float or int object versus a string object. I.e. modulo division versus string interpolation.
I've even seen documentation of some library that coopts `.__matmul__()` to do something with email addresses. It's not a library I use, just something I once saw the documentation on, so I'm not certain of details. But you can imagine that e.g. :
email = user @ domain
Could be helpful and reasonable (exact behavior and purpose could vary, but it's "something about email" iconically).
In other words, I'm not opposed to using the @ operator in my stringpy.Vector class out of purity about the meaning of operators. I just am not convinced that it actually adds anything that is not easier without it.