- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
gh-67748: DOC:Add summary table for str methods in stdtypes.rst #1709
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
Changes from 1 commit
937e8dd
              b3d4477
              7352386
              b577580
              e7ef462
              35a0649
              63227f9
              25ec485
              f1a2a6d
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -1376,6 +1376,108 @@ objects that compare equal might have different :attr:`~range.start`, | |
| single: str (built-in class); (see also string) | ||
| object: string | ||
|  | ||
| .. _text-methods-summary: | ||
|  | ||
| Text and Binary Sequence Type Methods Summary | ||
| ============================================= | ||
| The following table summarizes the text and binary sequence types methods by | ||
| category. | ||
|  | ||
|  | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | Category | str methods | bytes methods | | ||
| +==========================+==============================+==============================+ | ||
| | Formatting | :meth:`str.format` | | | ||
| + +------------------------------+------------------------------+ | ||
|          | ||
| | | :meth:`str.format_map` | | | ||
|          | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | Searching and Replacing | :meth:`str.find` | :meth:`bytes.find` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.rfind` | :meth:`bytes.rfind` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.index` | :meth:`bytes.index` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.rindex` | :meth:`bytes.rindex` | | ||
|          | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.startswith` | :meth:`bytes.startswith` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.endswith` | :meth:`bytes.endswith` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.count` | :meth:`bytes.count` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.replace` | :meth:`bytes.replace` | | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | Splitting and Joining | :meth:`str.split` | :meth:`bytes.split` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.splitlines` | :meth:`bytes.splitlines` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.rsplit` | :meth:`bytes.rsplit` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.partition` | :meth:`bytes.partition` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.rpartition` | :meth:`bytes.rpartition` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.join` | :meth:`bytes.join` | | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | String Classification | :meth:`str.isalpha` | :meth:`bytes.isalpha` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isdecimal` | | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isdigit` | :meth:`bytes.isdigit` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isnumeric` | | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isalnum` | :meth:`bytes.isalnum` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isidentifier` | | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.islower` | :meth:`bytes.islower` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isupper` | :meth:`bytes.isupper` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.istitle` | :meth:`bytes.istitle` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isspace` | :meth:`bytes.isspace` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.isprintable` | | | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | Case Manipulation | :meth:`str.lower` | :meth:`bytes.lower` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.upper` | :meth:`bytes.upper` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.casefold` | | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.capitalize` | :meth:`bytes.capitalize` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.title` | :meth:`bytes.title` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.swapcase` | :meth:`bytes.swapcase` | | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | Padding and Stripping | :meth:`str.ljust` | :meth:`bytes.ljust` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.rjust` | :meth:`bytes.rjust` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.center` | :meth:`bytes.center` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.zfill` | :meth:`bytes.zfill` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.expandtabs` | :meth:`bytes.expandtabs` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.strip` | :meth:`bytes.strip` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.lstrip` | :meth:`bytes.lstrip` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.rstrip` | :meth:`bytes.rstrip` | | ||
| +--------------------------+------------------------------+------------------------------+ | ||
| | Translation and Encoding | :meth:`str.translate` | :meth:`bytes.translate` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.maketrans` | :meth:`bytes.maketrans` | | ||
| + +------------------------------+------------------------------+ | ||
| | | :meth:`str.encode` | | | ||
| + +------------------------------+------------------------------+ | ||
| | | | :meth:`bytes.decode` | | ||
| +--------------------------+------------------------------+------------------------------+ | ||
|  | ||
| .. _textseq: | ||
|  | ||
| Text Sequence Type --- :class:`str` | ||
|  | @@ -1464,6 +1566,7 @@ multiple fragments. | |
| sections. In addition, see the :ref:`stringservices` section. | ||
|  | ||
|  | ||
|  | ||
|          | ||
| .. index:: | ||
| pair: string; methods | ||
|  | ||
|  | ||
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.
Is this paragraph necessary? It seems obvious just given the section and table headings.
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.
Thanks, Martin. You're right. I wasn't quite sure where to place this overall and thought there would probably be suggestions, so I kept it vague. There wasn't a section that combined both text and binary sequence types before and I didn't know if people would like having str and bytes (and bytearray) types all in one table or if there should be a separate table for each one under the existing sections.