[Python-ideas] Easily remove characters from a string.

Chris Angelico rosuav at gmail.com
Mon Oct 24 18:54:29 EDT 2016


On Tue, Oct 25, 2016 at 9:11 AM, Nathan Schneider <neatnate at gmail.com> wrote:
> What would be the expected behavior of "aabbccdd".replace(('a', 'aa'), ('x',
> 'y'))? It's not obvious to me whether longer replacement strings ('aa') or
> earlier replacement strings ('a') should take priority.

I'm actually not sure, so I would look at prior art. But in any case,
this is a question you can't even ask until replace() accepts multiple
arguments. Hence I'm +1 on the notion of simultaneous replacements
being supported.

ChrisA


More information about the Python-ideas mailing list