[Python-ideas] Infix functions

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Feb 23 23:53:46 CET 2014


Bruce Leban wrote:
> (2) Extended operators can be declared like this.
> 
>     class sample:
>         def '∩'(self, rhs):
>             return self.value.intersection(sample.get_set(rhs))

Or

    def __INTERSECTION__(self, rhs):
       ...

    def __rINTERSECTION__(self, rhs):
       ...

(i.e. use the Unicode character names.)

-- 
Greg


More information about the Python-ideas mailing list