[Python-ideas] Improve readability of long numeric literals

Random832 random832 at fastmail.com
Wed Feb 10 13:00:20 EST 2016


On Wed, Feb 10, 2016, at 12:51, Georg Brandl wrote:
> Underscores are allowed anywhere in numeric literals, except:
> 
> * at the beginning of a literal (obviously)
> * at the end of a literal
> * directly after a dot (since the underscore could start an attribute
> name)

I don't think it's particularly important to support this case, but the
sequence digit/dot/name with no spaces between is a syntax error now,
because the digit/dot is interpreted as a floating point constant.

> * directly after a sign in exponents (for consistency with leading signs)
> * in the middle of the "0x", "0o" or "0b" base specifiers

Do you allow multiple underscores in a row? I mentioned a couple
possible use cases for that.


More information about the Python-ideas mailing list