]> granicus.if.org Git - python/commitdiff
Close #16665: improve documentation for hex(). Patch by Jessica McKellar.
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 16 Mar 2014 01:12:20 +0000 (02:12 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 16 Mar 2014 01:12:20 +0000 (02:12 +0100)
Doc/library/functions.rst

index ae29cd8422ed8f4340c47f7fcd97197e378125ed..7ed25c1accc61b64a7556178654714fce9c3edf2 100644 (file)
@@ -608,9 +608,19 @@ are always available.  They are listed here in alphabetical order.
 
 .. 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::