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

Commitbf0f306

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 parent341bdd6 commitbf0f306

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
@@ -649,20 +649,23 @@ are always available. They are listed here in alphabetical order.
649649
sign may be ``'+'`` or ``'-'``; a ``'+'`` sign has no effect on the value
650650
produced. The argument may also be a string representing a NaN
651651
(not-a-number), or positive or negative infinity. More precisely, the
652-
input must conform to thefollowing grammar after leading and trailing
653-
whitespace characters are removed:
652+
input must conform to the``floatvalue`` production rule in the following
653+
grammar, after leading and trailingwhitespace characters are removed:
654654

655655
..productionlist::float
656656
sign: "+" | "-"
657657
infinity: "Infinity" | "inf"
658658
nan: "nan"
659-
numeric_value: `floatnumber` | `infinity` | `nan`
660-
numeric_string: [`sign`] `numeric_value`
661-
662-
Here ``floatnumber`` is the form of a Python floating-point literal,
663-
described in:ref:`floating`. Case is not significant, so, for example,
664-
"inf", "Inf", "INFINITY", and "iNfINity" are all acceptable spellings for
665-
positive infinity.
659+
digitpart: `digit` (["_"] `digit`)*
660+
number: [`digitpart`] "." `digitpart` | `digitpart` ["."]
661+
exponent: ("e" | "E") ["+" | "-"] `digitpart`
662+
floatnumber: number [`exponent`]
663+
floatvalue: [`sign`] (`floatnumber` | `infinity` | `nan`)
664+
665+
Here ``digit`` is a Unicode decimal digit (character in the Unicode general
666+
category ``Nd``). Case is not significant, so, for example, "inf", "Inf",
667+
"INFINITY", and "iNfINity" are all acceptable spellings for positive
668+
infinity.
666669

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp