diff options
author | Eric Appelt <eric.appelt@gmail.com> | 2018-03-10 02:44:12 -0600 |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2018-03-10 18:44:12 +1000 |
commit | 308eab979d153f1ab934383dc08bc4546ced8b6c (patch) | |
tree | bcc19dd71a3f513ac3089198b4f395f0491bff94 /Doc/reference | |
parent | 10485ebd40669d3e17ab4f477c8c898543bcccd1 (diff) | |
download | cpython-git-308eab979d153f1ab934383dc08bc4546ced8b6c.tar.gz |
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/reference')
-rw-r--r-- | Doc/reference/datamodel.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 8b127a0b7e..26ad7b8c05 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2377,6 +2377,15 @@ left undefined. of the appropriate type. +.. method:: object.__trunc__(self) + + Called to implement :meth:`math.trunc`. Should return the value of the + object truncated to a :class:`numbers.Integral` (typically an + :class:`int`). If a class defines :meth:`__trunc__` but not + :meth:`__int__`, then :meth:`__trunc__` is called to implement the + built-in function :func:`int`. + + .. method:: object.__index__(self) Called to implement :func:`operator.index`, and whenever Python needs to |