Tshepang Lekhonkhobe <tshepang@gmail.com> writes:
'foo bar baz'.replace(('foo', 'bar'), 'baz') baz baz baz
How about: '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. Do you think it's important to allow a set as the first argument to str.replace()? search_strings = set(['foo', 'bar']) 'foo bar baz'.replace(search_strings, 'foobar') I think that would be at least as desirable as your proposal; but what would be the order of replacements? -- \ “Shepherds … look after their sheep so they can, first, fleece | `\ them and second, turn them into meat. That's much more like the | _o__) priesthood as I know it.” —Christopher Hitchens, 2008-10-29 | Ben Finney