Clarify ord() and chr() documentation

This commit is contained in:
Nick Coghlan 2014-08-17 14:07:53 +10:00
parent e2953e5146
commit eed671910f

View file

@ -156,11 +156,13 @@ are always available. They are listed here in alphabetical order.
.. function:: chr(i) .. function:: chr(i)
Return the string representing a character whose Unicode codepoint is the integer Return the string representing a character whose Unicode codepoint is the
*i*. For example, ``chr(97)`` returns the string ``'a'``. This is the integer *i*. For example, ``chr(97)`` returns the string ``'a'``, while
inverse of :func:`ord`. The valid range for the argument is from 0 through ``chr(12491)`` returns the string ``'ニ'``. This is the inverse of
1,114,111 (0x10FFFF in base 16). :exc:`ValueError` will be raised if *i* is :func:`ord`.
outside that range.
The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in
base 16). :exc:`ValueError` will be raised if *i* is outside that range.
.. function:: classmethod(function) .. function:: classmethod(function)
@ -1056,13 +1058,12 @@ are always available. They are listed here in alphabetical order.
The ``'U'`` mode. The ``'U'`` mode.
.. XXX works for bytes too, but should it?
.. function:: ord(c) .. function:: ord(c)
Given a string representing one Unicode character, return an integer Given a string representing one Unicode character, return an integer
representing the Unicode code representing the Unicode code point of that character. For example,
point of that character. For example, ``ord('a')`` returns the integer ``97`` ``ord('a')`` returns the integer ``97`` and ``ord('ニ')`` returns
and ``ord('\u2020')`` returns ``8224``. This is the inverse of :func:`chr`. ``12491``. This is the inverse of :func:`chr`.
.. function:: pow(x, y[, z]) .. function:: pow(x, y[, z])