[Python-ideas] SI scale factors in Python

M.-A. Lemburg mal at egenix.com
Sat Aug 27 08:36:11 EDT 2016


I've been following this discussion on and off for a while, but
still fail to see how SI units, factors or the like are a use
case which is general enough to warrant changing the language.

There are packages available on PyPI for dealing with this
in a similar way we deal with decimal literals in Python:

C extension:

https://pypi.python.org/pypi/cfunits/
http://pythonhosted.org/cfunits/cfunits.Units.html
(interfaces to the udunits-2 lib:
http://www.unidata.ucar.edu/software/udunits/udunits-2.2.20/doc/udunits/udunits2.html)

Pure python:

https://pypi.python.org/pypi/units/

IMHO, a literal notation like "2 m" is more likely related to
a missing operator which should be flagged as SyntaxError
than the declaration of an integer with associated unit.
By keeping such analysis to string to object conversion
tools/functions you make the intent explicit, which
allows for better error reporting.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Aug 27 2016)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
                      http://www.malemburg.com/



More information about the Python-ideas mailing list