Skip to content

Commit 6ba72fe

Browse files
Rewrite.
1 parent 642ba4a commit 6ba72fe

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

Doc/library/functions.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,15 +1564,16 @@ are always available. They are listed here in alphabetical order.
15641564

15651565
.. function:: ord(character, /)
15661566

1567-
The argument must be a one-character string or a :class:`bytes` or
1568-
:class:`bytearray` object of length 1.
1569-
If it is a one-character string, return an integer
1570-
representing the Unicode code point of that character. For example,
1567+
Return the ordinal value of a character.
1568+
1569+
If the argument is a one-character string, return the Unicode code point
1570+
of that character. For example,
15711571
``ord('a')`` returns the integer ``97`` and ``ord('€')`` (Euro sign)
15721572
returns ``8364``. This is the inverse of :func:`chr`.
15731573

1574-
If the argument is a :class:`!bytes` or :class:`!bytearray` object of
1575-
length 1, return an integer value of its element.
1574+
If the argument is a :class:`bytes` or :class:`bytearray` object of
1575+
length 1, return its single byte value.
1576+
For example, ``ord(b'a')`` returns the integer ``97``.
15761577

15771578

15781579
.. function:: pow(base, exp, mod=None)

Python/bltinmodule.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,15 +2121,18 @@ ord as builtin_ord
21212121
character as c: object
21222122
/
21232123
2124-
Return the Unicode code point for a one-character string.
2124+
Return the ordinal value of a character.
21252125
2126-
Return the value of the first byte for a bytes or bytearray object of
2127-
length 1.
2126+
If the argument is a one-character string, return the Unicode code
2127+
point of that character.
2128+
2129+
If the argument is a bytes or bytearray object of length 1, return its
2130+
single byte value.
21282131
[clinic start generated code]*/
21292132

21302133
static PyObject *
21312134
builtin_ord(PyObject *module, PyObject *c)
2132-
/*[clinic end generated code: output=4fa5e87a323bae71 input=99e491d094680598]*/
2135+
/*[clinic end generated code: output=4fa5e87a323bae71 input=98d38480432e1177]*/
21332136
{
21342137
long ord;
21352138
Py_ssize_t size;

Python/clinic/bltinmodule.c.h

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)