[Python-checkins] cpython (merge 3.3 -> default): Close #16665: improve documentation for hex(). Patch by Jessica McKellar.
antoine.pitrou
python-checkins at python.org
Sun Mar 16 02:16:58 CET 2014
http://hg.python.org/cpython/rev/c267f4eb8173
changeset: 89682:c267f4eb8173
parent: 89679:21ecc3d52806
parent: 89680:464c22bf9fe1
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Mar 16 02:13:07 2014 +0100
summary:
Close #16665: improve documentation for hex(). Patch by Jessica McKellar.
files:
Doc/library/functions.rst | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -617,9 +617,19 @@
.. function:: hex(x)
- Convert an integer number to a hexadecimal string. The result is a valid Python
- expression. If *x* is not a Python :class:`int` object, it has to define an
- :meth:`__index__` method that returns an integer.
+ Convert an integer number to a lowercase hexadecimal string
+ prefixed with "0x", for example:
+
+ >>> hex(255)
+ '0xff'
+ >>> hex(-42)
+ '-0x2a'
+
+ If x is not a Python :class:`int` object, it has to define an __index__()
+ method that returns an integer.
+
+ See also :func:`int` for converting a hexadecimal string to an
+ integer using a base of 16.
.. note::
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list