Terry J. Reedy added the comment:
Sorry, as with all similar subclasses, class op subclass = class unless one
explicitly subclasses the answer or overrides the __op__ method to do that for
you.
class octint(int):
'int that displays as octal'
def __str__(self):
return oct(self)
__repr__ = __str__
mode = octint(0o640)
print(mode + 4, octint(mode+4))
def __add__(self, other):
return octint(int.__add__(self, other))
# octint(self+other) is infinite recursion
octint.__add__ = __add__
print(mode+4)
>>>
420 0o644
0o644
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16801>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com