FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106487: Allow the 'count' argument of `str.replace` to be a keyword by hugovk · Pull Request #106488 · python/cpython · GitHub

/ cpython Public

gh-106487: Allow the 'count' argument of str.replace to be a keyword - #106488

Merged
hugovk merged 4 commits into
python:mainfrom
hugovk:str-replace-keyword-count
Jul 10, 2023
Merged

gh-106487: Allow the 'count' argument of str.replace to be a keyword#106488
hugovk merged 4 commits into
python:mainfrom
hugovk:str-replace-keyword-count

Conversation

hugovk commented Jul 6, 2023
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

Before

>>> "aa".replace("a", "b")
'bb'
>>> "aa".replace("a", "b", 1)
'aa'
>>> "aa".replace("a", "b", count=1)
TypeError: str.replace() takes no keyword arguments

After

>>> "aa".replace("a", "b")
'bb'
>>> "aa".replace("a", "b", 0)
'aa'
>>> "aa".replace("a", "b", count=0)
'aa'
>>> "aa".replace("a", "b", 1)
'ba'
>>> "aa".replace("a", "b", count=1)
'ba'
>>> "aa".replace("a", "b", 2)
'bb'
>>> "aa".replace("a", "b", count=2)
'bb'
>>> "aa".replace("a", "b", 3)
'bb'
>>> "aa".replace("a", "b", count=3)
'bb'

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

hugovk changed the title gh-106487: Allow the *count* argument of str.replace to be a keyword gh-106487: Allow the 'count' argument of str.replace to be a keyword Jul 6, 2023
Comment thread Doc/library/stdtypes.rst

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

hugovk merged commit 34c1414 into python:main Jul 10, 2023
hugovk deleted the str-replace-keyword-count branch July 10, 2023 09:52

vstinner commented Jul 10, 2023
edited
Loading

Copy link
Copy Markdown
Member

Nice enhancement. It's funny to have Mastodon driven development 😁

hugovk commented Jul 10, 2023

Copy link
Copy Markdown
Member Author

T[witter]DD is so last year.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.13 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL