Matteo asked a question about units (but hijacked another discussion
to do so) :-)

-------------
Hi All,
I'm trying to use sympy for units conversion..
I use this code to convert from ft to mm..
cad_leng=units.Unit('cad_leng','mm')
converter={units.m: cad_leng*Rational(1000)}
cad_ft=units.ft
cad_mm=cad_ft.subs(converter)
mm_value=float(str(cad_mm.evalf()).split('*')[0])
print mm_value
304.8

Is this right ?
Or there are any other method to get it ?
-------------

Matteo, I would do it like this:

>>> from sympy.physics import units as u
>>> u.feet/u.mm
1524/5
>>> _.n()
304.800000000000

Just divide the quantity you have by the quantity that you want (the
way that axis labels on a graph are often reported to suggest unitless
quantities like length/m to mean that the numbers are lengths divided
by meters).

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to