problem deriving form type long

Frederic Rentsch anthra.norell at vtxmail.ch
Wed Jan 23 08:08:01 EST 2008


Gabriel Genellina wrote:
> En Mon, 21 Jan 2008 18:33:10 -0200, Frederic Rentsch
> <anthra.norell at vtxmail.ch> escribió:
>
>> Hi, here's something that puzzles me:
>>
>>  >>> class Fix_Point (long):
>>         def __init__ (self, l):
>>            long.__init__ (self, l * 0x10000):
>>
>>  >>> fp = Fix_Point (99)
>>  >>> fp
>>     99
>
> You have to override __new__, not __init__. Immutable types like numbers
> and tuples don't use __init__.
> See http://docs.python.org/ref/customization.html
That's a big help! Thank you very much.

Frederic




More information about the Python-list mailing list