Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard pythonic way to treat physical units / quantities in python?

Tags:

Is there a standard pythonic way to treat physical units / quantities in python? I saw different module-specific solutions from different fields like physics or neuroscience. But I would rather like to use a standard method than "island"-solutions as others should be able to easily read my code.

like image 487
Philipp der Rautenberg Avatar asked Jul 28 '09 12:07

Philipp der Rautenberg


People also ask

How do you calculate units in Python?

To assign a unit to a quantity, multiply by the unit, e.g. my_length = 100 * mm. (In normal text you would write “100 mm”, but unfortunately Python does not have “implied multiplication”.)


2 Answers

quantities seems to be gaining a lot of traction lately.

like image 172
Autoplectic Avatar answered Sep 21 '22 06:09

Autoplectic


The best solution is the Unum package. a de-facto standard, imho.

like image 25
Stefano Borini Avatar answered Sep 19 '22 06:09

Stefano Borini