I'm interested in subclassing the built-in int
type in Python (I'm using v. 2.5), but having some trouble getting the initialization working.
Here's some example code, which should be fairly obvious.
class TestClass(int):
def __init__(self):
int.__init__(self, 5)
However, when I try to use this I get:
>>> a = TestClass()
>>> a
0
where I'd expect the result to be 5
.
What am I doing wrong? Google, so far, hasn't been very helpful, but I'm not really sure what I should be searching for
Question&Answers:os