Skip to content

Conversation

@kovan
Copy link
Contributor

@kovan kovan commented Feb 3, 2026

Summary

  • Adds an example showing how to use str.translate with a dictionary mapping directly
  • Demonstrates character replacement ('a''X', 'b''Y') and deletion ('c'None)

Test plan

  • make check passed
  • Documentation builds correctly

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://cpython-previews--144454.org.readthedocs.build/

character-to-character mappings in different formats.

The following example uses a mapping to replace ``'a'`` with ``'X'``,
``'b'`` with ``'Y'``, and delete ``'c'``::
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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::.

kovan and others added 2 commits February 9, 2026 18:20
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>
@kovan kovan force-pushed the gh-72798-str-translate-example branch from 30e9c5b to 4328d06 Compare February 9, 2026 17:23
@kovan
Copy link
Contributor Author

kovan commented Feb 9, 2026

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented Feb 9, 2026

Thanks for making the requested changes!

: please review the changes made to this pull request.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner vstinner merged commit 9b8d59c into python:main Feb 10, 2026
35 of 37 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Feb 10, 2026
@vstinner
Copy link
Member

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants