New submission from João Bernardo <jbv...@gmail.com>: I'm having trouble subclassing the int type and I think this behavior is a bug... (Python 3.2)
>>> class One(int): def __init__(self): super().__init__(1) >>> one = One() >>> one + 2 2 >>> one == 0 True I know `int` objects are immutable but my `One` class should be mutable... and why it doesn't raise an error? That gives the same result on Python 2.7 using super properly. Also, if that's not a bug, how it should be done to achieve "one + 2 == 3" without creating another attribute. Things I also tried: self.real = 1 #readonly attribute error int.__init__(self, 1) #same behavior I Couldn't find any related issues... sorry if it's repeated. ---------- components: Interpreter Core messages: 140161 nosy: JBernardo priority: normal severity: normal status: open title: Extending int class type: behavior versions: Python 2.7, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12538> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com