On Sat, Jun 3, 2017 at 3:42 PM, Pavol Lisy <[email protected]> wrote: > Sorry for probably stupid question! Is something like -> > > class A: > def __oper__(self, '⊞', other): > return something(self.value, other) > > a = A() > a ⊞ 3 > > thinkable?
No, because operators need to be defined before you get to individual objects, and they need precedence and associativity. So it'd have to be defined at the compiler level. Also, having arbitrary operators gets extremely confusing. It's not easy to reason about code when you don't know what's even an operator. Not a stupid question, but one for which the answer is "definitely not like that". ChrisA _______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
