Skip to content

Commit 7488c79

Browse files
bpo-26701: Tweak the documentation for special methods in int(). (GH-6741)
(cherry picked from commit df00f04) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 8ac158a commit 7488c79

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Doc/library/functions.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ are always available. They are listed here in alphabetical order.
657657
.. function:: hex(x)
658658

659659
Convert an integer number to a lowercase hexadecimal string prefixed with
660-
"0x". If x is not a Python :class:`int` object, it has to define an
661-
__index__() method that returns an integer. Some examples:
660+
"0x". If *x* is not a Python :class:`int` object, it has to define an
661+
:meth:`__index__` method that returns an integer. Some examples:
662662

663663
>>> hex(255)
664664
'0xff'
@@ -716,12 +716,10 @@ are always available. They are listed here in alphabetical order.
716716
int(x, base=10)
717717

718718
Return an integer object constructed from a number or string *x*, or return
719-
``0`` if no arguments are given. If *x* is a number, return
720-
:meth:`x.__int__() <object.__int__>`. If *x* defines
721-
:meth:`x.__trunc__() <object.__trunc__>` but not
722-
:meth:`x.__int__() <object.__int__>`, then return
723-
:meth:`x.__trunc__() <object.__trunc__>`. For floating point numbers,
724-
this truncates towards zero.
719+
``0`` if no arguments are given. If *x* defines :meth:`__int__`,
720+
``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`__trunc__`,
721+
it returns ``x.__trunc__()``.
722+
For floating point numbers, this truncates towards zero.
725723

726724
If *x* is not a number or if *base* is given, then *x* must be a string,
727725
:class:`bytes`, or :class:`bytearray` instance representing an :ref:`integer

0 commit comments

Comments
 (0)