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, [email protected], 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 <[email protected]>
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, [email protected], serhiy.storchaka
2013-02-25 06:08:47terry.reedysetmessageid: <[email protected]>
2013-02-25 06:08:47terry.reedylinkissue16801 messages
2013-02-25 06:08:47terry.reedycreate