summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-05-10 13:38:44 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2018-05-10 13:38:44 (GMT)
commitdf00f048250b9a07195b0e3b1c5c0161fdcc9db8 (patch)
tree7e7b28f92cd11f0b8d50ad57739c55f4b5a689c8 /Doc/library
parentb00854caa080cec613496d3a5e1b0891c9ff83e6 (diff)
downloadcpython-df00f048250b9a07195b0e3b1c5c0161fdcc9db8.zip
cpython-df00f048250b9a07195b0e3b1c5c0161fdcc9db8.tar.gz
cpython-df00f048250b9a07195b0e3b1c5c0161fdcc9db8.tar.bz2
bpo-26701: Tweak the documentation for special methods in int(). (GH-6741)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/functions.rst14
1 files changed, 6 insertions, 8 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 2d15001..3b05a3a 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -671,8 +671,8 @@ are always available. They are listed here in alphabetical order.
.. function:: hex(x)
Convert an integer number to a lowercase hexadecimal string prefixed with
- "0x". If x is not a Python :class:`int` object, it has to define an
- __index__() method that returns an integer. Some examples:
+ "0x". If *x* is not a Python :class:`int` object, it has to define an
+ :meth:`__index__` method that returns an integer. Some examples:
>>> hex(255)
'0xff'
@@ -730,12 +730,10 @@ are always available. They are listed here in alphabetical order.
int(x, base=10)
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__>`. If *x* defines
- :meth:`x.__trunc__() <object.__trunc__>` but not
- :meth:`x.__int__() <object.__int__>`, then return
- :meth:`x.__trunc__() <object.__trunc__>`. For floating point numbers,
- this truncates towards zero.
+ ``0`` if no arguments are given. If *x* defines :meth:`__int__`,
+ ``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`__trunc__`,
+ it returns ``x.__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