[Python-ideas] Improve readability of long numeric literals
Paul Moore
p.f.moore at gmail.com
Wed Feb 10 04:44:02 EST 2016
On 10 February 2016 at 03:32, Joshua Landau <joshua at landau.ws> wrote:
> On 10 February 2016 at 02:46, Chris Angelico <rosuav at gmail.com> wrote:
>> On Wed, Feb 10, 2016 at 1:18 PM, Joshua Landau <joshua at landau.ws> wrote:
>>> On 10 February 2016 at 00:45, MRAB <python at mrabarnett.plus.com> wrote:
>>>> The Ada programming language allows underscores in numerals, but requires
>>>> there to be a digit on both sides of the underscore.
>>>
>>> +1 to this.
>>
>> I'm not sure how that would get encoded into the grammar, but
>> certainly that's the advice I would recommend for style guides.
>
> You do the BNF equivalent of turning \d\d* to \d(\d|_\d)*. It should
> be really simple.
It's possible to get it right, but I think keeping the grammar simple
and making the rest a style issue is the best approach. We don't
disallow 0x6AfEbbC for example, but mixing case like that is ugly to
read too.
(I was originally going to say "Under that change, "23" becomes
invalid" but then I realised I'd misread the grammar. Which sort of
makes my point that we want to keep the rules simple :-))
Paul
More information about the Python-ideas
mailing list