From d8a41c6f16a52e117d63e988906343229839004c Mon Sep 17 00:00:00 2001 From: csabella Date: Tue, 28 Mar 2017 12:12:37 -0400 Subject: [PATCH 1/4] bpo-29677: DOC: clarify documentation for `round` Changed the parameter name from 'number' to 'x' to be consistent with documentation for other numeric functions, such as abs, float, math.floor, and mail.ceil. The use of 'number' seemed to indicate an object from the Number class, which with PEP 3141 was not valid for round since round is implemented for Real and not Complex. Not sure about this one, but changed the phrase '*ndigits* digits' to be "*ndigits* precision' to match the help() text. Moved the delegation line and expanded it to match the similar line in the float() section since that is the only other built-in over the Real class. --- Doc/library/functions.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 2c0ea71c47f413..8cbbc60bba5f1c 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1252,11 +1252,11 @@ are always available. They are listed here in alphabetical order. arguments starting at ``0``). -.. function:: round(number[, ndigits]) +.. function:: round(x[, ndigits]) - Return the floating point value *number* rounded to *ndigits* digits after - the decimal point. If *ndigits* is omitted or is ``None``, it returns the - nearest integer to its input. Delegates to ``number.__round__(ndigits)``. + Return a number *x* rounded to *ndigits* precision after the + decimal point. If *ndigits* is omitted or is ``None``, it returns the + nearest integer to its input. For the built-in types supporting :func:`round`, values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are @@ -1264,7 +1264,10 @@ are always available. They are listed here in alphabetical order. both ``round(0.5)`` and ``round(-0.5)`` are ``0``, and ``round(1.5)`` is ``2``). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if called with one argument, - otherwise of the same type as *number*. + otherwise of the same type as *x*. + + For a general Python object ``x``, ``round(x, ndigits)`` delegates to + ``x.__round__(ndigits)``. .. note:: From 89347b76840843660ad24adaa7a6a0853468ed3c Mon Sep 17 00:00:00 2001 From: csabella Date: Tue, 28 Mar 2017 13:17:32 -0400 Subject: [PATCH 2/4] Update functions.rst --- Doc/library/functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 8cbbc60bba5f1c..f823cf95502217 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1265,7 +1265,7 @@ are always available. They are listed here in alphabetical order. ``2``). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if called with one argument, otherwise of the same type as *x*. - + For a general Python object ``x``, ``round(x, ndigits)`` delegates to ``x.__round__(ndigits)``. From 4586a8af65b1016f696f5281bc37f15831093099 Mon Sep 17 00:00:00 2001 From: csabella Date: Tue, 28 Mar 2017 17:41:17 -0400 Subject: [PATCH 3/4] bpo-29677: DOC: clarify documentation for `round` --- Doc/library/functions.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index f823cf95502217..90fb07af227d98 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1252,10 +1252,10 @@ are always available. They are listed here in alphabetical order. arguments starting at ``0``). -.. function:: round(x[, ndigits]) +.. function:: round(number[, ndigits]) - Return a number *x* rounded to *ndigits* precision after the - decimal point. If *ndigits* is omitted or is ``None``, it returns the + Return *number* rounded to *ndigits* precision after the decimal + point. If *ndigits* is omitted or is ``None``, it returns the nearest integer to its input. For the built-in types supporting :func:`round`, values are rounded to the @@ -1264,10 +1264,10 @@ are always available. They are listed here in alphabetical order. both ``round(0.5)`` and ``round(-0.5)`` are ``0``, and ``round(1.5)`` is ``2``). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if called with one argument, - otherwise of the same type as *x*. + otherwise of the same type as *number*. - For a general Python object ``x``, ``round(x, ndigits)`` delegates to - ``x.__round__(ndigits)``. + For a general Python object ``number``, ``round(number, ndigits)`` delegates to + ``number.__round__(ndigits)``. .. note:: From ec3c188d265d71ce895460313803d7261e7b1053 Mon Sep 17 00:00:00 2001 From: Cheryl Sabella Date: Wed, 29 Mar 2017 20:00:13 -0400 Subject: [PATCH 4/4] bpo-29917: DOC: Remove link from PyMethodDef In C-API, The link target of the "type" struct member is the Python built-in "type". --- Doc/c-api/structures.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index f48119391f2bbd..c080f317bee9d9 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -241,7 +241,7 @@ definition with the same method name. +==================+=============+===============================+ | :attr:`name` | char \* | name of the member | +------------------+-------------+-------------------------------+ - | :attr:`type` | int | the type of the member in the | + | :attr:`!type` | int | the type of the member in the | | | | C struct | +------------------+-------------+-------------------------------+ | :attr:`offset` | Py_ssize_t | the offset in bytes that the | @@ -256,7 +256,7 @@ definition with the same method name. | | | docstring | +------------------+-------------+-------------------------------+ - :attr:`type` can be one of many ``T_`` macros corresponding to various C + :attr:`!type` can be one of many ``T_`` macros corresponding to various C types. When the member is accessed in Python, it will be converted to the equivalent Python type.