[Python-Dev] PEP 515: Underscores in Numeric Literals (original) (raw)

Steven D'Aprano steve at pearwood.info
Wed Feb 10 18:14:46 EST 2016


On Wed, Feb 10, 2016 at 10:53:09PM +0000, Paul Moore wrote:

On 10 February 2016 at 22:20, Georg Brandl <g.brandl at gmx.net> wrote: > This came up in python-ideas, and has met mostly positive comments, > although the exact syntax rules are up for discussion.

+1 on the PEP. Is there any value in allowing underscores in strings passed to the Decimal constructor as well? The same sorts of justifications would seem to apply. It's perfectly arguable that the change for Decimal would be so rarely used as to not be worth it, though, so I don't mind either way in practice.

Let's delay making any change to string conversions for now, and that includes Decimal. We can also do this:

Decimal("123_456_789.00000_12345_67890".replace("_", ""))

for those who absolutely must include underscores in their numeric strings. The big win is for numeric literals, not numeric string conversions.

-- Steve



More information about the Python-Dev mailing list