Hello Python gurus!
I need to subclass the built-in type "int" and to add a method that resets the value to what it was when the class was first instantiated.
here is what i want to achieve:
a = my_int(4)
print a ---> prints 4 (works ok)
a += 5
print a ---> prints 9 (works ok)
print a ---> doesnt work
Here is how far i got in creating this class:
class my_int(int): def __new__(cls,arg=0): __v = arg return int.__new__(cls,arg) def reset(self): int.__init__(self, __v) ---> this doesnt work. neither does "self = __v" .
so how do i set the value of the int (parent class) from within the method ?