[Python-ideas] in str.replace(old, new), allow 'old' to accept a tuple
Carl M. Johnson
cmjohnson.mailinglist at gmail.com
Thu Apr 12 03:59:34 CEST 2012
On Apr 11, 2012, at 3:47 PM, Ben Finney wrote:
> 'foo bar baz'.replace(('foo', 'bar'), 'foobar')
>
> You can't replace multiple matches “at the same time”, as you're
> implying. The order of replacements is important, since it will affect
> the outcome in many cases.
Can't you say the same about 'a b c'.replace("a", "aa")?
I think the case of the needles overlapping is more to your point though.
"abc".replace( ("ab", "bc"), "b")
What should that produce? "bc"? "b"? "ab" even (if we ignore the order of the tuple)?
More information about the Python-ideas
mailing list