diff options
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/index.rst | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/documentation/index.rst b/documentation/index.rst index ffbe10f..473e39b 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -31,6 +31,10 @@ Indices and tables Package contents ---------------- +.. data:: PY2 + + A boolean indicating if the code is running on Python 2. + .. data:: PY3 A boolean indicating if the code is running on Python 3. @@ -76,11 +80,12 @@ Six provides constants that may differ between Python versions. Ones ending .. data:: MAXSIZE - The maximum size of a container. This is equivalent to - :data:`py3:sys.maxsize` in Python 2.6 and later (including 3.x). Note, this - is temptingly similar to, but not the same as :data:`py2:sys.maxint` in - Python 2. There is no direct equivalent to :data:`py2:sys.maxint` in Python - 3 because its integer type has no limits aside from memory. + The maximum size of a container like :func:`py3:list` or :func:`py3:dict`. + This is equivalent to :data:`py3:sys.maxsize` in Python 2.6 and later + (including 3.x). Note, this is temptingly similar to, but not the same as + :data:`py2:sys.maxint` in Python 2. There is no direct equivalent to + :data:`py2:sys.maxint` in Python 3 because its integer type has no limits + aside from memory. Here's example usage of the module:: @@ -291,7 +296,7 @@ string data in all Python versions. with the latin-1 encoding to bytes. -.. note:: + .. note:: Since all Python versions 2.6 and after support the ``b`` prefix, :func:`b`, code without 2.5 support doesn't need :func:`b`. @@ -319,12 +324,24 @@ string data in all Python versions. ASCII data. +.. function:: unichr(c) + + Return the (Unicode) string representing the codepoint *c*. This is + equivalent to :func:`py2:unichr` on Python 2 and :func:`py3:chr` on Python 3. + + .. function:: int2byte(i) Converts *i* to a byte. *i* must be in ``range(0, 256)``. This is equivalent to :func:`py2:chr` in Python 2 and ``bytes((i,))`` in Python 3. +.. function:: byte2int(bs) + + Converts the first byte of *bs* to an integer. This is equivalent to + ``ord(bs[0])`` on Python 2 and ``bs[0]`` on Python 3. + + .. function:: indexbytes(buf, i) Return the byte at index *i* of *buf* as an integer. This is equivalent to |