Message182921
| Author |
terry.reedy |
| Recipients |
Arfrever, barry, carsten.klein@axn-software.de, ezio.melotti, georg.brandl, larry, mark.dickinson, r.david.murray, rhettinger, serhiy.storchaka, terry.reedy |
| Date |
2013年02月25日.06:08:47 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1361772527.45.0.535325328719.issue16801@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| 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 |
|