Форум сайта python.su
python 2.6.5 Мой пример работает, правда, дествительно не так как нужно:
>>> class MyInt(int):
... def __init__(self, number):
... super(MyInt, self).__init__(number)
...
>>> a = MyInt(12)
/usr/bin/bpython:4: DeprecationWarning: object.__init__() takes no parameters
import sys
>>> a
12
>>> 10-a
-2
>>> type(a)
<class '__main__.MyInt'>
>>>
>>> a =12
>>> a
12
>>> type(a)
<type 'int'>
>>> a = MyInt(5)
>>> f = a +1
>>> type(f)
<type 'int'>
>>> f = 1+a
>>> type(f)
<type 'int'>
>>>
Офлайн