problem deriving form type long
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Jan 21 16:19:14 EST 2008
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
> (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.)
You can read this thru the Google Groups interfase:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/ade1fdc42c5380b8/
or using Gmane:
http://thread.gmane.org/gmane.comp.python.general/555822
--
Gabriel Genellina
More information about the Python-list
mailing list