This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add str.replaceall?
Type: enhancement Stage:
Components: Unicode Versions: Python 3.10
process
Status: open Resolution: later
Dependencies: Superseder:
Assigned To: Nosy List: Nathaniel Manista, ezio.melotti, rhettinger, steven.daprano, vstinner
Priority: normal Keywords:

Created on 2021-01-24 14:20 by Nathaniel Manista, last changed 2022-04-11 14:59 by admin.

Messages (5)
msg385581 - (view) Author: Nathaniel Manista (Nathaniel Manista) Date: 2021-01-24 14:20
Chained str.replace calls can sometimes be pretty unattractive; what are the chances that we could have an str.replaceall method? Of type Callable[[Mapping[str, str]], str]?

Check out absl::StrReplaceAll (https://github.com/abseil/abseil-cpp/blob/22771d471930ce88e1e75d0ca9dd8c65a7b0f895/absl/strings/str_replace.h#L73-L98) for a similarly useful function in C++.
msg385616 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-25 10:41
Hi, the bug tracker is not the right place to propose to add a new method to the builtin str type. I suggest to propose it on the python-ideas list. I'm quite sure that it was proposed at least once, so please search in the archives.
msg385617 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-25 10:43
https://mail.python.org/mailman3/lists/python-ideas.python.org/
msg385687 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-01-26 01:44
Versions 3.6-3.9 are all in feature-freeze, so the earliest this could be added is version 3.10.
msg385842 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-01-28 06:21
Marking as "pending" while a discussion takes place on python-ideas.
History
Date User Action Args
2022-04-11 14:59:40adminsetstatus: pending -> open
github: 87181
2021-01-28 06:21:23rhettingersetstatus: open -> pending

nosy: + rhettinger
messages: + msg385842

resolution: later
2021-01-26 01:44:59steven.dapranosetnosy: + steven.daprano

messages: + msg385687
versions: - Python 3.6, Python 3.7, Python 3.8, Python 3.9
2021-01-25 10:43:44vstinnersetmessages: + msg385617
2021-01-25 10:41:44vstinnersetmessages: + msg385616
2021-01-24 14:20:03Nathaniel Manistacreate