[Edu-sig] Uints in Python
Jeff Sandys
sandysj at juno.com
Wed Feb 23 23:53:41 CET 2005
If you are interested in doing units with Python,
Unum by Pierre Denis is the package for you.
It is compatible NumPy.
http://home.tiscali.be/be052320/Unum.html
>>> from unum.units import *
>>> distance = 1 * MILE
>>> distance.as(NMILE)
0.868974082073 [nmi]
>>> distance.as(M)
1609.34 [m]
>>> height = 4 * M
>>> area = height * distance
>>> area
6437.36 [m2]
>>> area.as(ARE)
64.3736 [a]
(an ARE is a metric acre)
I have had some arguements with Pierre with his
implementation of CELSIUS. His resonable arguement
is that you usually don't multiply temperatures
(degrees squared has no meaning) and you are mostly
concerned with temperature differences. But I think
that when you ask for the conversion with "as" it
should say that 1 degree Kelvin is -272.16 degrees
Centigrade. I will redo the "as" method to take care
of this.
>>> space = 2.5 * K
>>> space
2.5 [K]
>>> delta_space = .5 * CELSIUS
>>> space - delta_space
2.0 [deg C]
>>> space.as(CELSIUS)
2.5 [deg C]
It is a cool package that I highly recommend for
educational Python.
Thanks,
Jeff Sandys
___________________________________________________________________
Speed up your surfing with Juno SpeedBand.
Now includes pop-up blocker!
Only $14.95/month -visit http://www.juno.com/surf to sign up today!
More information about the Edu-sig
mailing list