GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-67748: DOC:Add summary table for str methods in stdtypes.rst by csabella · Pull Request #1709 · python/cpython

Conversation

@csabella

@csabella csabella commented May 22, 2017 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Based on the original patch by Martin Panter to create a table categorizing str methods.

https://bugs.python.org/issue23560

  • Issue: Group the docs of similar methods in stdtypes.rst #67748

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label May 22, 2017
@serhiy-storchaka
serhiy-storchaka requested review from ezio-melotti and vadmium May 22, 2017 06:07
vadmium
vadmium reviewed May 27, 2017
View reviewed changes

@vadmium vadmium left a comment

Copy link
Copy Markdown
Member

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.

I don’t have much of an opinion about adding this table comparing the methods that are available. If others think it would be good to add, don’t let me get in your way :)

FWIW I don’t think it helps with Ezio’s original goal to remove duplication and make the documentation shorter. But I don’t see a good way to accomplish that and at the same time satisfy @rhettinger by keeping an entry for each method in alphabetical order.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/stdtypes.rst Outdated

@vadmium vadmium May 27, 2017

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@csabella csabella May 27, 2017

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@csabella

csabella commented May 27, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@vadmium Thanks for your comments. I hope others chime in. Being fairly new to Python, I've found my chart (or your changes) very helpful in using the right str functions. To your point, it didn't really do much to shorten the page though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@csabella
bpo-23560: DOC:Add summary table for str methods in stdtypes.rst
937e8dd
@csabella
csabella force-pushed the bpo23560 branch from 096ff95 to 937e8dd Compare June 1, 2017 23:14
ezio-melotti
ezio-melotti requested changes Oct 13, 2017
View reviewed changes
Comment thread Doc/library/stdtypes.rst Outdated
+==========================+==============================+==============================+
| Formatting | :meth:`str.format` | |
+ +------------------------------+------------------------------+
| | :meth:`str.format_map` | |

@ezio-melotti ezio-melotti Oct 13, 2017

Copy link
Copy Markdown
Member

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.

Maybe __mod__ (%) should be included here too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@csabella csabella Oct 21, 2017

Copy link
Copy Markdown
Contributor Author

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.

I've added some lines for the printf-style and for f-strings. I think I linked them to the best places for a description.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/stdtypes.rst Outdated
| Category | str methods | bytes methods |
+==========================+==============================+==============================+
| Formatting | :meth:`str.format` | |
+ +------------------------------+------------------------------+

@ezio-melotti ezio-melotti Oct 13, 2017

Copy link
Copy Markdown
Member

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.

I think the leftmost + can/should be a |.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

csabella reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@csabella csabella Oct 21, 2017

Copy link
Copy Markdown
Contributor Author

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/stdtypes.rst Outdated
+ +------------------------------+------------------------------+
| | :meth:`str.index` | :meth:`bytes.index` |
+ +------------------------------+------------------------------+
| | :meth:`str.rindex` | :meth:`bytes.rindex` |

@ezio-melotti ezio-melotti Oct 13, 2017

Copy link
Copy Markdown
Member

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.

Perhaps the methods and their corresponding rmethods could be combined on the same line to make the table more compact. If however the end result isn't more readable, you could leave them separate.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@csabella csabella Oct 21, 2017

Copy link
Copy Markdown
Contributor Author

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.

I added the methods and rmethods on the same lines, but I did it 2 different ways so that you could pick which one you prefer. find\rfind and index\rindex are done as columns while split\rsplit, ljust\rjust, and lstrip/rstrip are done as or.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/stdtypes.rst Outdated
sections. In addition, see the :ref:`stringservices` section.



@ezio-melotti ezio-melotti Oct 13, 2017

Copy link
Copy Markdown
Member

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.

Was this change intentional?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@csabella csabella Oct 21, 2017

Copy link
Copy Markdown
Contributor Author

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 for catching that! I've removed it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot

bedevere-bot commented Oct 13, 2017

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting changes label Oct 13, 2017
csabella added 3 commits October 21, 2017 11:26
@csabella
Correct use of + where there was no intersection
b3d4477
@csabella
Reformat to show left and right on same row
7352386
@csabella
Add other methods of string formatting
b577580
@csabella

csabella commented Oct 21, 2017

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Oct 21, 2017

Copy link
Copy Markdown

Thanks for making the requested changes!

@ezio-melotti: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting changes labels Oct 21, 2017
@adorilson

adorilson commented Mar 22, 2021

Copy link
Copy Markdown
Contributor

@ezio-melotti Do you review this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Feb 19, 2022

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Feb 19, 2022
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jul 28, 2022
@github-actions

github-actions Bot commented Aug 28, 2022

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 28, 2022
@ezio-melotti
Merge branch 'main' into bpo23560
e7ef462
@ezio-melotti ezio-melotti changed the title bpo-23560: DOC:Add summary table for str methods in stdtypes.rst gh-67748: DOC:Add summary table for str methods in stdtypes.rst Aug 30, 2022
@ezio-melotti

ezio-melotti commented Aug 30, 2022

Copy link
Copy Markdown
Member

This is how the (first half of the) table looks like. The table intentionally splits some cells and uses a | on others to show two alternative styles.

image

One issue with the table is that it takes over a page and it has a lot of whitespace. Maybe we could do something that looks like this instead (using a proper colspan):

Searching and Replacing
str str.find/str.rfind, str.index/str.rindex, str.startswith/str.endswith, str.count, str.replace
bytes bytes.find/bytes.rfind, bytes.index/bytes.rindex, bytes.startswith/bytes.endswith, bytes.count, bytes.replace
Splitting and Joining
str str.split/str.rsplit, str.splitlines, str.partition/str.rpartition,str.join
bytes bytes.split/bytes.rsplit, bytes.splitlines, bytes.partition/bytes.rpartition, bytes.join

We lose the direct mapping from str to the equivalent bytes method, but since they are still grouped it's easy enough to find it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ezio-melotti
ezio-melotti requested a review from CAM-Gerlach August 30, 2022 21:20
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 31, 2022
@CAM-Gerlach CAM-Gerlach added the docs Documentation in the Doc dir label Aug 31, 2022
@CAM-Gerlach CAM-Gerlach added the skip news label Aug 31, 2022
@CAM-Gerlach

CAM-Gerlach commented Aug 31, 2022

Copy link
Copy Markdown
Member

Hmm, well take my opinion as just one data point, but while I do definitely see the concern of it being rather long, at least from what I can see so far, I find the current format a good deal easier to skim and consult as a structured summary, at least personally to my eyes. If we're going to go with a structure similar to what you propose, I'm not sure if we even need a table at all, as opposed to just a bulleted list, which has essentially the same structure, is even more compact and is simpler to read and write, e.g.

  • Searching and Replacing
    • str.find/str.rfind, str.index/str.rindex, str.startswith/str.endswith, str.count, str.replace
    • bytes.find/bytes.rfind, bytes.index/bytes.rindex, bytes.startswith/bytes.endswith, bytes.count, bytes.replace
  • Splitting and Joining
    • str.split/str.rsplit, str.splitlines, str.partition/str.rpartition, str.join
    • bytes.split/bytes.rsplit, bytes.splitlines, bytes.partition/bytes.rpartition, bytes.join

Meanwhile, the original table could be made more compact and maintainable, at least in the source, by formatting it as a list-table rather than a full literal table.

Also, of the two styles, FWIW a real cell split rather than a raw | looks a lot cleaner and clearer to me.

ezio-melotti reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ezio-melotti

ezio-melotti commented Sep 1, 2022

Copy link
Copy Markdown
Member

See also these issues:

  • Automatically tabulate module contents in the docs #83545
  • Create a ToC entry for every function, method, class, etc sphinx-doc/sphinx#6316
CAM-Gerlach reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 2, 2022

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 2, 2022
@arhadthedev
Merge branch 'main' into bpo23560
35a0649
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Apr 26, 2023
@github-actions

github-actions Bot commented May 27, 2023

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 27, 2023
@dg-pb dg-pb mentioned this pull request Oct 23, 2024
Doc: Add a single table as summary to math documentation #125810
Merged
willingc
willingc approved these changes Oct 31, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting change review labels Oct 31, 2024
@willingc
Merge branch 'main' into bpo23560
63227f9
@willingc
willingc requested a review from ezio-melotti October 31, 2024 02:00
@willingc

willingc commented Oct 31, 2024

Copy link
Copy Markdown
Contributor

@ezio-melotti I'm going through and rebooting and/or closing old Docs PRs. This one looks good and is an improvement over not having it. Would you be cool with merging? There would always be the option to iterate on it in the future. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Oct 31, 2024
@github-actions

github-actions Bot commented Nov 30, 2024

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Nov 30, 2024
encukou
encukou reviewed Dec 19, 2024
View reviewed changes
Comment thread Doc/library/stdtypes.rst Outdated
Comment on lines +1575 to +1577
+--------------------------+-------------------------------------------+---------------------------------------------------+
| Splitting and Joining | :meth:`str.split` | :meth:`str.rsplit` | :meth:`bytes.split` | :meth:`bytes.rsplit` |
+--------------------------+-------------------------------------------+---------------------------------------------------+

@encukou encukou Dec 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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 r/l pairs (split/rsplit, ljust/rjust, lstrip/rstrip) need +s to render as table cells:

Suggested change
+--------------------------+-------------------------------------------+---------------------------------------------------+
| Splitting and Joining | :meth:`str.split` | :meth:`str.rsplit` | :meth:`bytes.split` | :meth:`bytes.rsplit` |
+--------------------------+-------------------------------------------+---------------------------------------------------+
+--------------------------+-------------------+-----------------------+---------------------+-----------------------------+
| Splitting and Joining | :meth:`str.split` | :meth:`str.rsplit` | :meth:`bytes.split` | :meth:`bytes.rsplit` |
+--------------------------+-------------------+-----------------------+---------------------+-----------------------------+

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ezio-melotti reacted with eyes emoji
All reactions
  • 👀 1 reaction
@encukou

encukou commented Dec 19, 2024

Copy link
Copy Markdown
Member

I agree that it's an improvement and can be iterated on.
If there are no objections, I'll merge early next year.

ezio-melotti reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Dec 19, 2024
encukou added 2 commits January 7, 2025 14:30
@encukou
Merge in the main branch
25ec485
@encukou
Fix table formatting
f1a2a6d
@encukou
encukou merged commit 5044c22 into python:main Jan 13, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 13, 2025
@ezio-melotti ezio-melotti mentioned this pull request Apr 10, 2022
Group the docs of similar methods in stdtypes.rst #67748
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou left review comments
@vadmium vadmium vadmium left review comments
@willingc willingc willingc approved these changes
@CAM-Gerlach CAM-Gerlach Awaiting requested review from CAM-Gerlach
@ezio-melotti ezio-melotti Awaiting requested review from ezio-melotti

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@csabella @bedevere-bot @adorilson @ezio-melotti @CAM-Gerlach @willingc @encukou @vadmium @the-knights-who-say-ni @arhadthedev
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.