Python discourages using operators for things that don't have anything to do with their original use. If you try to be too clever with it, you run into issues. For instance, comparison operators are chained, so that `x > y > z` is equivalent to `x > y and y > z`, not `(x > y) > z`.
The most radical use of operators in the standard library that I know of is in pathlib, where `Path('/usr') / 'lib' == Path('/usr/lib')`, and I think that got a lot of pushback. It's certainly an outlier.
It fits well with Python's overall approach to readability. If the meaning of your operator isn't immediately apparent from its existing meanings, then it should probably just be a regular old named function or method instead. Python doesn't like DSLs very much.
Programmer-defined operators are certainly useful, but Python went in the other direction, which has its own advantages. C++'s choice to have a fixed set of operators but overload them in a lot of arbitrary ways is probably the worst of both worlds.
You should look at the Construct library, which overloads the '/' operator as syntactic sugar to make s-expressions in it's DSL less paren-heavy. I'm not saying I agree, but it was wild when I first saw it.
> Python discourages using operators for things that don't have anything to do with their original use.
Python doesn't really discourage anything and especially not overloading operators in weird ways. You even pointed out the pathlib insanity in the stdlib. Python isn't the shiny bastion of consistency and obviousness that the zen claimed it was years ago
The most radical use of operators in the standard library that I know of is in pathlib, where `Path('/usr') / 'lib' == Path('/usr/lib')`, and I think that got a lot of pushback. It's certainly an outlier.
It fits well with Python's overall approach to readability. If the meaning of your operator isn't immediately apparent from its existing meanings, then it should probably just be a regular old named function or method instead. Python doesn't like DSLs very much.
Programmer-defined operators are certainly useful, but Python went in the other direction, which has its own advantages. C++'s choice to have a fixed set of operators but overload them in a lot of arbitrary ways is probably the worst of both worlds.