◐ Shell
clean mode source ↗

Message 62361 - Python tracker

Hi,

the attached code in t.py fails to run:
class C (object):
    def __ror__ (self, other):
        return 42
print C() | C()

$ python t.py
Traceback (most recent call last):
  File "t.py", line 5, in ?
    print C() | C()
TypeError: unsupported operand type(s) for |: 'C' and 'C'

If I use old style classes (ie. "class C:" instead of "class
C(object):"), the code runs fine. I suspect that the method lookup for
special operator methods is different in new style classes, but why?
This might also be related to issue #643841 but I am not sure.