[issue33647] Add re.replace(string, replacement_map)

2020-10-08 Thread Chris Jerdonek
Chris Jerdonek added the comment: Another API option is to use str.replace's existing arguments: str.replace(old, new[, count]). In addition to "old" and "new" being strings, they could also be lists of strings of equal length, similar to how str.maketrans() can accept two strings of equal l

[issue33647] Add re.replace(string, replacement_map)

2018-05-26 Thread Paal Pedersen
Paal Pedersen added the comment: I forgot to put the ** in the input. This is to further explain what I had in mind: """The meaning of this file is to show how the replace function can be enhanced""" # Today the replace api takes at most 3 arguments, old_string, new_string, and optional numbe

[issue33647] Add re.replace(string, replacement_map)

2018-05-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm -1 of adding support of this in str.replace. This is very non-trivial code, and unicodeobject.c is already one of largest and most complex files. Adding new complex code will make maintaining harder and can make the compiler producing less optimal code

[issue33647] Add re.replace(string, replacement_map)

2018-05-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I would like an example added to the sub(pattern, function, > string) examples. That seems like the most reasonable way to go. -- nosy: +rhettinger ___ Python tracker

[issue33647] Add re.replace(string, replacement_map)

2018-05-25 Thread Terry J. Reedy
Terry J. Reedy added the comment: Your proposal is underspecified. (And 'yours' is inconsistent with 'your';-). If you want sequential replacememt in multiple scans, make sequential replace calls. Use a loop if the number of replacement scans is variable or large. To be sure of the order o