Skip to content

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

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

Merged
merged 4 commits into from
Jul 10, 2023

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jul 6, 2023

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

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

vstinner commented Jul 10, 2023

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

@hugovk
Copy link
Member Author

hugovk commented Jul 10, 2023

T[witter]DD is so last year.

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