Message140161
| Author |
JBernardo |
| Recipients |
JBernardo |
| Date |
2011年07月11日.20:26:02 |
| SpamBayes Score |
4.097402e-08 |
| Marked as misclassified |
No |
| Message-id |
<1310415963.68.0.740269303687.issue12538@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年07月11日 20:26:03 | JBernardo | set | recipients:
+ JBernardo |
| 2011年07月11日 20:26:03 | JBernardo | set | messageid: <1310415963.68.0.740269303687.issue12538@psf.upfronthosting.co.za> |
| 2011年07月11日 20:26:03 | JBernardo | link | issue12538 messages |
| 2011年07月11日 20:26:02 | JBernardo | create |
|