-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
gh-137668: Document that ord() supports also bytes and bytearray #137669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-137668: Document that ord() supports also bytes and bytearray #137669
Conversation
Doc/library/functions.rst
Outdated
|
||
Given a string representing one Unicode character, return an integer | ||
The argument must be a one-character string or a :class:`bytes` or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are now duplicated; what about:
character must be of length 1.
If it is a :class:str
return …
If it is a :class:bytes
or :class:bytearray
object, return …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternate suggestion: Give the length restriction once in the initial summary sentence. "Return an integer representing a character, a length 1 str, bytes, or bytearray. If a string, return the unicode ... inverse ... char. For bytes or bytearray, return the integer itself."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if remove any concrete types from the initial line, and only mentioned them in type-specific descriptions?
Doc/library/functions.rst
Outdated
|
||
Given a string representing one Unicode character, return an integer | ||
The argument must be a one-character string or a :class:`bytes` or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if remove any concrete types from the initial line, and only mentioned them in type-specific descriptions?
|
||
Given a string representing one Unicode character, return an integer | ||
representing the Unicode code point of that character. For example, | ||
Return the ordinal value of a character. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The ordinal value" is from the description of the original ord()
function in Pascal. It explains the name of the function and can help to mnemonize it.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
pythonGH-137669) (cherry picked from commit 35759fe) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sorry, @serhiy-storchaka, I could not cleanly backport this to
|
GH-137703 is a backport of this pull request to the 3.14 branch. |
…ytearray (pythonGH-137669) (cherry picked from commit 35759fe) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-137704 is a backport of this pull request to the 3.13 branch. |
📚 Documentation preview 📚: https://cpython-previews--137669.org.readthedocs.build/