gene tani wrote:
> Russ wrote:
>
>>Does it ever make sense to derive a class from a basic type such as
>>float or int? Suppose, for example, that I want to create a class for
>>physical scalars with units. I thought about deriving from float, then
>>adding the units. I played around with it a bit,
Russ wrote:
> Does it ever make sense to derive a class from a basic type such as
> float or int? Suppose, for example, that I want to create a class for
> physical scalars with units. I thought about deriving from float, then
> adding the units. I played around with it a bit, but it doesn't seem
On Tue, 21 Feb 2006 15:01:22 -0600
Robert Kern <[EMAIL PROTECTED]> wrote:
> http://www.python.org/2.2.3/descrintro.html#__new__
Curiously, __new__ does not appear in the index of
the Python 2.3 language reference!
It is fixed in Python 2.4, though -- I just checked.
--
Terry Hancock ([EMAIL PRO
Russ enlightened us with:
> The problem is that when I derive a new class from float, the darn
> thing won't let me create a constructor that accepts more than one
> argument.
Use __new__, not __init__. It's the function that's called when a new
immutable object is created.
Sybren
--
The problem
Russ wrote:
> The problem is that when I derive a new class from float, the darn
> thing won't let me create a constructor that accepts more than one
> argument. I need two arguments: one for the numerical value and one for
> the units. But when I try to give the constructor two arguments, I get
>
The problem is that when I derive a new class from float, the darn
thing won't let me create a constructor that accepts more than one
argument. I need two arguments: one for the numerical value and one for
the units. But when I try to give the constructor two arguments, I get
this when I call the c
Probably this is interesting for you:
http://home.tiscali.be/be052320/Unum.html
I think its API can be improved, but it can be used.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Russ enlightened us with:
> Does it ever make sense to derive a class from a basic type such as
> float or int? Suppose, for example, that I want to create a class
> for physical scalars with units.
That makes sense.
> I thought about deriving from float, then adding the units. I played
> around
Does it ever make sense to derive a class from a basic type such as
float or int? Suppose, for example, that I want to create a class for
physical scalars with units. I thought about deriving from float, then
adding the units. I played around with it a bit, but it doesn't seem to
work very well. Am