Python parsing for units

Say I have a set of strings, for example:

"5 m^2" "17 sq feet" "3 inches" "89 meters" 

Is there a Python package that will read such lines, convert them to SI, and return the result in a convenient form for use? For example:

 >>> a=dream_parser.parse("17 sq feet") >>> a.quantity 1.5793517 >>> a.type 'area' >>> a.unit 'm^2' 
+8
python units-of-measurement
source share
2 answers

Is there an extension for ipython that can do at least part of what you want. It is called ipython-physics

It saves value and units and allows (at least) some basic math. I never used it myself, so I don’t know how easy it would be to use a python script

+1
source share

More recently, pint is a good place for most of them.

+1
source share

All Articles