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

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