-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
gh-72798: Add mapping example to str.translate documentation #144454
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
Conversation
Doc/library/stdtypes.rst
Outdated
| character-to-character mappings in different formats. | ||
|
|
||
| The following example uses a mapping to replace ``'a'`` with ``'X'``, | ||
| ``'b'`` with ``'Y'``, and delete ``'c'``:: |
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.
Can you use .. doctest:: here?
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 other examples in stdtypes.rst (e.g. the str.title() example just above) consistently use :: with >>> prompts rather than .. doctest::. I kept the same style for consistency. Would you still prefer .. doctest:: here?
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.
Yes, I would prefer .. doctest::.
Add an example showing how to use str.translate with a dictionary mapping directly, demonstrating character replacement and deletion. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30e9c5b to
4328d06
Compare
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! : please review the changes made to this pull request. |
vstinner
left a comment
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.
LGTM
|
Merged, thanks. |
Summary
str.translatewith a dictionary mapping directly'a'→'X','b'→'Y') and deletion ('c'→None)Test plan
make checkpassed🤖 Generated with Claude Code
📚 Documentation preview 📚: https://cpython-previews--144454.org.readthedocs.build/