diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-03-10 15:10:45 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2018-03-10 15:10:45 (GMT) |
commit | 1028ca4f04c14cf40a8f3e7951623a96ec0143c2 (patch) | |
tree | 8231cce71807da12d61a752828ea229053fa7129 /Doc/library | |
parent | 19b42fe97cc15ff123f7ccb61a26fed817e850f7 (diff) | |
download | cpython-1028ca4f04c14cf40a8f3e7951623a96ec0143c2.zip cpython-1028ca4f04c14cf40a8f3e7951623a96ec0143c2.tar.gz cpython-1028ca4f04c14cf40a8f3e7951623a96ec0143c2.tar.bz2 |
bpo-26701: Add documentation for __trunc__ (GH-6050)
`int` fails back to `__trunc__` is `__int__` isn't defined, so cover
that in the docs.
(cherry picked from commit 308eab979d153f1ab934383dc08bc4546ced8b6c)
Co-authored-by: Eric Appelt <eric.appelt@gmail.com>
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/functions.rst | 7 | ||||
-rw-r--r-- | Doc/library/math.rst | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index bc42030..9cb6b0e 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -717,8 +717,11 @@ are always available. They are listed here in alphabetical order. Return an integer object constructed from a number or string *x*, or return ``0`` if no arguments are given. If *x* is a number, return - :meth:`x.__int__() <object.__int__>`. For floating point numbers, this - truncates towards zero. + :meth:`x.__int__() <object.__int__>`. If *x* defines + :meth:`x.__trunc__() <object.__trunc__>` but not + :meth:`x.__int__() <object.__int__>`, then return + if :meth:`x.__trunc__() <object.__trunc__>`. For floating point numbers, + this truncates towards zero. If *x* is not a number or if *base* is given, then *x* must be a string, :class:`bytes`, or :class:`bytearray` instance representing an :ref:`integer diff --git a/Doc/library/math.rst b/Doc/library/math.rst index da2b8cc..0f36a3f 100644 --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -179,7 +179,7 @@ Number-theoretic and representation functions Return the :class:`~numbers.Real` value *x* truncated to an :class:`~numbers.Integral` (usually an integer). Delegates to - ``x.__trunc__()``. + :meth:`x.__trunc__() <object.__trunc__>`. Note that :func:`frexp` and :func:`modf` have a different call/return pattern |