[Python-ideas] SI scale factors alone, without units or dimensional analysis

MRAB python at mrabarnett.plus.com
Fri Aug 26 11:27:56 EDT 2016


On 2016-08-26 14:34, Chris Angelico wrote:
> On Fri, Aug 26, 2016 at 10:47 PM, Steven D'Aprano <steve at pearwood.info> wrote:
[snip]
>> Or if that's too heavy (two whole characters, plus the suffix!) perhaps
>> we could have a rule that the suffix must follow the final underscore
>> of the number:
>>
>> 8_M  # int 8*10*6
>> 123_456_789_M  # int 123456789*10**6
>> 123_M_456  # still an error
>> 8._M  # float 8.0*10**6
>
> This sounds better IMO. It's not legal syntax in any version of Python
> older than 3.6, so there's minimal backward compatibility trouble.
>
According to Wikipedia, it's recommended that there be a space between 
the number and the units, thus not "1kg" but "1 kg".

As we don't put spaces inside numbers in Python, insisting on an 
underscore instead would seem to be a reasonable compromise.



More information about the Python-ideas mailing list