python-dev
[Prev] Thread [Next] | [Prev] Date [Next]
Re: [Python-Dev] Adding syntax for units of measure skip Tue Jun 23 22:00:22 2009
>> Has anyone added special syntax to allow writing numeric literals with
>> physical units? So you can write 12m + 34cm, and would get 12.34m.
...
Georg> normally you wouldn't add units to the language itself.
...
Georg> For the interactive shell, using a wrapper that allows simplified
Georg> input is also a possibility, like IPython's "-profile physics"
Georg> mode, or something like http://bitbucket.org/birkenfeld/phsh/
Georg> which allows you to write
>>>> `1 m` + `12 cm`
Georg> 1.12 m
Also, check out the magnitude module (in PyPI). I use it to specify the
units of the computation but allow users to input values using units which
are meaningful to them. So, for example, if a value has units of time they
could enter 1m or 60s and get the same internal value.
Skip
_______________________________________________
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