Message182921
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 |
|
| Date |
User |
Action |
Args |
| 2013-02-25 06:08:47 | terry.reedy | set | recipients:
+ terry.reedy, barry, georg.brandl, rhettinger, mark.dickinson, larry, ezio.melotti, Arfrever, r.david.murray, carsten.klein@axn-software.de, serhiy.storchaka |
| 2013-02-25 06:08:47 | terry.reedy | set | messageid: <1361772527.45.0.535325328719.issue16801@psf.upfronthosting.co.za> |
| 2013-02-25 06:08:47 | terry.reedy | link | issue16801 messages |
| 2013-02-25 06:08:47 | terry.reedy | create | |
|