homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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:47terry.reedysetrecipients: + 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:47terry.reedysetmessageid: <1361772527.45.0.535325328719.issue16801@psf.upfronthosting.co.za>
2013年02月25日 06:08:47terry.reedylinkissue16801 messages
2013年02月25日 06:08:47terry.reedycreate

AltStyle によって変換されたページ (->オリジナル) /