mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-26701: Add documentation for __trunc__ (GH-6022)
`int` fails back to `__trunc__` is `__int__` isn't defined, so cover that in the docs.
This commit is contained in:
parent
10485ebd40
commit
308eab979d
3 changed files with 15 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue