[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

problem deriving form type long

Frederic Rentsch

1/21/2008 8:33:00 PM

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

With prints:

>>> class Fix_Point (long):
def __init__ (self, l):
print l
l_ = l * 2
print l_
long.__init__ (self, l_)
print self

>>> fp = Fix_Point (99)
99
198
99

I have tried dozens of variations: type casts, variables, ... nothing
doing. Fix_Point instances always get the argument assigned regardless
of the transformation __init__ () performs on it prior to calling
long.__init__ (). Looks like long.__init__ () isn't called at all. Any
idea anyone what's going on?

Frederic


(P.S. I am not currently a subscriber. I was and had to bail out when I
couldn't handle the volume anymore. To subscribe just to post one
question doesn't seem practical at all. So, I don't even know if this
message goes through. In case it does, I would appreciate a CC directly
to my address, as I don't think I can receive the list. Thanks a million.)