Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0dea924

Browse files
gh-100428: Make float documentation more accurate (GH-100437)
Previously, the grammar did not accept `float("10")`.Also implement mdickinson's suggestion of removing the indirection.(cherry picked from commit2e1a9ce)Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
1 parent3ea6f7f commit0dea924

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

‎Doc/library/functions.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -628,20 +628,23 @@ are always available. They are listed here in alphabetical order.
628628
sign may be ``'+'`` or ``'-'``; a ``'+'`` sign has no effect on the value
629629
produced. The argument may also be a string representing a NaN
630630
(not-a-number), or positive or negative infinity. More precisely, the
631-
input must conform to thefollowing grammar after leading and trailing
632-
whitespace characters are removed:
631+
input must conform to the``floatvalue`` production rule in the following
632+
grammar, after leading and trailingwhitespace characters are removed:
633633

634634
..productionlist::float
635635
sign: "+" | "-"
636636
infinity: "Infinity" | "inf"
637637
nan: "nan"
638-
numeric_value: `floatnumber` | `infinity` | `nan`
639-
numeric_string: [`sign`] `numeric_value`
640-
641-
Here ``floatnumber`` is the form of a Python floating-point literal,
642-
described in:ref:`floating`. Case is not significant, so, for example,
643-
"inf", "Inf", "INFINITY", and "iNfINity" are all acceptable spellings for
644-
positive infinity.
638+
digitpart: `digit` (["_"] `digit`)*
639+
number: [`digitpart`] "." `digitpart` | `digitpart` ["."]
640+
exponent: ("e" | "E") ["+" | "-"] `digitpart`
641+
floatnumber: number [`exponent`]
642+
floatvalue: [`sign`] (`floatnumber` | `infinity` | `nan`)
643+
644+
Here ``digit`` is a Unicode decimal digit (character in the Unicode general
645+
category ``Nd``). Case is not significant, so, for example, "inf", "Inf",
646+
"INFINITY", and "iNfINity" are all acceptable spellings for positive
647+
infinity.
645648

646649
Otherwise, if the argument is an integer or a floating point number, a
647650
floating point number with the same value (within Python's floating point

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp