deriving from float or int

Robert Kern robert.kern at gmail.com
Tue Feb 21 19:47:40 EST 2006


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, but it doesn't seem to
>>work very well. Am I missing something here? Thanks.
> 
> you could look at how sciPy does it:
> http://starship.python.net/~hinsen/ScientificPython/

ScientificPython != SciPy

ScientificPython's unit package does not subclass from floats since it tries to
be agnostic about the kind of value you can assign a unit to.

-- 
Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list