diff options
author | Eric Appelt <eric.appelt@gmail.com> | 2018-03-10 08:44:12 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2018-03-10 08:44:12 (GMT) |
commit | 308eab979d153f1ab934383dc08bc4546ced8b6c (patch) | |
tree | bcc19dd71a3f513ac3089198b4f395f0491bff94 /Doc/library/functions.rst | |
parent | 10485ebd40669d3e17ab4f477c8c898543bcccd1 (diff) | |
download | cpython-308eab979d153f1ab934383dc08bc4546ced8b6c.zip cpython-308eab979d153f1ab934383dc08bc4546ced8b6c.tar.gz cpython-308eab979d153f1ab934383dc08bc4546ced8b6c.tar.bz2 |
bpo-26701: Add documentation for __trunc__ (GH-6022)
`int` fails back to `__trunc__` is `__int__` isn't defined, so cover
that in the docs.
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r-- | Doc/library/functions.rst | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 3ddd280..c3b6385 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -731,8 +731,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 |