Commit c7692805 authored by Antoine Pitrou's avatar Antoine Pitrou

Close #16665: improve documentation for hex(). Patch by Jessica McKellar.

parent e530f268
...@@ -596,8 +596,21 @@ available. They are listed here in alphabetical order. ...@@ -596,8 +596,21 @@ available. They are listed here in alphabetical order.
.. function:: hex(x) .. function:: hex(x)
Convert an integer number (of any size) to a hexadecimal string. The result is a Convert an integer number (of any size) to a lowercase hexadecimal string
valid Python expression. prefixed with "0x", for example:
>>> hex(255)
'0xff'
>>> hex(-42)
'-0x2a'
>>> hex(1L)
'0x1L'
If x is not a Python :class:`int` or :class:`long` 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:: .. note::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment