The C++ way is custom literals (it's where this thread originated)

https://mail.python.org/archives/list/python-ideas@python.org/thread/MFZ52D32YTPYIQVUEZJWW3DUYQUBR5R7/

One problem I am seeing is a misunderstanding between standard, well-defined 
units, and technical lingo - for which I am not advocating native language 
support. Also, standard units here does not mean universal constants. There is 
no reason or need to provide any kind of new language support for those.

The problem as described in my original post (rant?) is that without units, any 
computational code is less WYSIWYG. C++ has a way to deal with units in literal 
expressions, why not Python? And no, language support alone is not enough, 
since NumPy and SciPy would have to add code to implement as well, and then 
there is data entry (command line arguments, config files, web forms, etc.). 
Native language support is not a magic bullet, but it is a bullet.

> The register_numeric_suffix idea would create a true global namespace,
> independent of the module system. That seems like a bad idea: libraries
> should be able to use their own units internally without potentially
> breaking other libraries. Units should be local to each module. You need a
> way to import them into your module's unit namespace. You might want to
> import only some of the units exported by a unit provider...

The reason I disagree with this view is that units of measurement are fixed. 
I'm sure that when I say this, some will be reminded of trauma that they have 
experienced with "datetime" objects and UTC jujitsu, but those are not the 
same. Units of measure are immutable, and have only one proper meaning. PEP 20 
says "There should be one-- and preferably only one --obvious way to do it. 
[sic]" Seems like that should apply to units as well. In fact, for mechanical 
engineering software packages like SolidWorks there already is a standard for 
unit conversions:

https://en.wikipedia.org/wiki/Unified_Code_for_Units_of_Measure
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/5KSAKAGRJTPUXEBOL7LMSR753CSVWOTB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to