[Python-ideas] SI scale factors in Python

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Aug 25 01:57:15 EDT 2016


Chris Angelico wrote:
> If units are retained, what you have is no longer a simple number, but
> a value with a unit, and is a quite different beast. (For instance,
> addition would have to cope with unit mismatches (probably by throwing
> an error), and multiplication would have to combine the units (length
> * length = area).)

And that can be surprisingly tricky. For example, newtons
times metres equals joules -- but *only* if the force and
the distance are in the same direction, otherwise it's
torque rather than energy and the units are just
newton-metres.

-- 
Greg


More information about the Python-ideas mailing list