python-dev
[Prev] Thread [Next] | [Prev] Date [Next]
Re: [Python-Dev] Adding syntax for units of measure Christian Heimes Tue Jun 23 04:00:37 2009
Tobias C. Rittweiler schrieb: > Hi! > > Has anyone added special syntax to allow writing numeric literals with > physical units? So you can write 12m + 34cm, and would get 12.34m. > > My question is how would you modify the BNF the most sensible way to > allow for this? The above example is simple, but think of 42 km/h. You don't need special syntax in order to work with units. You just need to normalize all input to SI units like meter, second and meter per second: km=1000. m=1. dm=0.1 cm=0.01 mm=0.001 s= 1. h = 3600. m_s=m/s km_h=km/h length_in_mm = (12*m + 34*cm)/mm speed = 5*km_h For what purpose do you want to have physical units in Python syntax? Do you need to verify your formulas? Christian _______________________________________________ Python-Dev mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/alexiscircle%40gmail.com
- [Python-Dev] Adding syntax for units of measure Tobias C. Rittweiler
- Re: [Python-Dev] Adding syntax for units of measure Terry Reedy
- Re: [Python-Dev] Adding syntax for units of measure Christian Heimes <=
- Re: [Python-Dev] Adding syntax for units of measure Georg Brandl