-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align the grammar of the Decimal
string constructor with float
's
#128185
Comments
Whtat do you mean digits of a decimal? a Do you mean it's not specified on the docs? namely that you can have |
Yes, but the documentation on that seems outdated, since the grammar mentioned in the docs does not mention the underscore style. |
Well.. it says (emphasis mine)
So technically, it's fine? we don't want to overcharge the grammar I think. |
Well the grammar for the |
I see. I think it would be fine if we remove the mention of underscores in the text and add it to the grammar. Concerning leading and trailing whitespaces, I think this should be outside the grammar. WDYT? |
Decimal
string constructor with float
's
It's not. >>> Decimal('1__.__2')
Decimal('1.2')
>>> float('1__.__2')
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
float('1__.__2')
~~~~~^^^^^^^^^^^
ValueError: could not convert string to float: '1__.__2' That's known, see e.g. #88433
It's ok. So far we have an important module in the stdlib (called "this").
That's what it does: "If value is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters, as well as underscores throughout, are removed: [grammar follows]". |
What I meant is to remove "as well as underscores throughout" and put the but for decimals, we have so we could update |
The grammar does not cover the case with underscores between the digits of a Decimal. The PEP-515 introduced underscores for integers, floating-point numbers and decimals. The documentation for integers and floating-point numbers are updated to cover underscores, but the grammar documentation for the
Decimal
does not.The text was updated successfully, but these errors were encountered: