A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/issues/106487 below:

Allow `str.replace`'s 'count' to be a keyword argument · Issue #106487 · python/cpython · GitHub

Skip to content Navigation Menu

Saved searches Use saved searches to filter your results more quickly

Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert Additional navigation options

Allow str.replace's 'count' to be a keyword argument #106487

Description Feature or enhancement

Allow the count argument of str.replace to be a keyword to better describe its use.

Pitch

str.replace takes old and new strings as parameters, and an optional count parameter:

https://docs.python.org/3/library/stdtypes.html#str.replace

However, count cannot be a keyword argument:

>>> "aaa".replace("a", "b", 2)
'bba'
>>> "aaa".replace("a", "b", count=2)
TypeError: str.replace() takes no keyword arguments

It would be more explicit if the count parameter could also be a keyword, so there's no doubt about its meaning.

Previous discussion

Suggested by @treyhunner at https://mastodon.social/@treyhunner/110664375381530126

Linked PRs

AlexWaygood, treyhunner, jugmac00, tusharsadhwani, williamdavie and 10 more

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4