Skip to content

Commit 22df418

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 8ffff34 commit 22df418

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
@@ -671,8 +671,8 @@ are always available. They are listed here in alphabetical order.
671671
.. function:: hex(x)
672672

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

677677
>>> hex(255)
678678
'0xff'
@@ -730,12 +730,10 @@ are always available. They are listed here in alphabetical order.
730730
int(x, base=10)
731731

732732
Return an integer object constructed from a number or string *x*, or return
733-
``0`` if no arguments are given. If *x* is a number, return
734-
:meth:`x.__int__() <object.__int__>`. If *x* defines
735-
:meth:`x.__trunc__() <object.__trunc__>` but not
736-
:meth:`x.__int__() <object.__int__>`, then return
737-
:meth:`x.__trunc__() <object.__trunc__>`. For floating point numbers,
738-
this truncates towards zero.
733+
``0`` if no arguments are given. If *x* defines :meth:`__int__`,
734+
``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`__trunc__`,
735+
it returns ``x.__trunc__()``.
736+
For floating point numbers, this truncates towards zero.
739737

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

0 commit comments

Comments
 (0)