[Python-Dev] PEP 515: Underscores in Numeric Literals (original) (raw)
Georg Brandl g.brandl at gmx.net
Thu Feb 11 04:39:53 EST 2016
- Previous message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Next message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 02/11/2016 10:10 AM, Paul Moore wrote:
On 10 February 2016 at 23:14, Steven D'Aprano <steve at pearwood.info> wrote:
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("123456789.000001234567890".replace("", "")) for those who absolutely must include underscores in their numeric strings. The big win is for numeric literals, not numeric string conversions. Good point. Maybe add this as an example in the PEP to explain why conversions are excluded. But I did only mean the Decimal constructor, which I think of more as a "decimal literal" - whereas int() and float() are (in my mind at least) conversion functions and as such should not be coupled to literal format (for example, 0x0001 notation isn't supported by int())
Actually, it is. Just not without a base argument, because the default base is 10. But both with base 0 and base 16, '0x' prefixes are allowed.
That's why I'm leaning towards supporting the underscores. In any case I'm preparing the implementation.
Georg
- Previous message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Next message (by thread): [Python-Dev] PEP 515: Underscores in Numeric Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]