[Python-ideas] Improve readability of long numeric literals

Guido van Rossum guido at python.org
Tue Feb 9 18:17:36 EST 2016


Indeed, "123 456" is a no-no, but "123_456" sound good. (Not sure
about "12_34_56" but there are probably use cases for that too.)

On Tue, Feb 9, 2016 at 3:02 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 02/09/2016 01:40 PM, Manuel CerĂ³n wrote:
>
>> Sometimes it's hard to read long numbers. For example:
>>
>>  >>> opts.write_buffer_size = 67108864
>>
>> Some languages (Ruby, Perl, Swift) allow the use of underscores in
>> numeric literals, which are ignored. They are typically used as
>> thousands separators. The example above would look like this:
>>
>>  >>> opts.write_buffer_size = 67_108_864
>
>
> As I recall, a number of years ago we had this discussion and Guido approved
> the idea.  The only email I could locate at the moment, though, shows his
> support of the idea, but not outright approval. [1]
>
> I dare say if somebody submitted a patch it would fare well.  (As in: be
> accepted, not gone forever.)
>
> --
> ~Ethan~
>
>
>
> [1] https://mail.python.org/pipermail/python-ideas/2011-May/010157.html
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list