[Python-ideas] in str.replace(old, new), allow 'old' to accept a tuple

Nick Coghlan ncoghlan at gmail.com
Thu Apr 12 06:56:16 CEST 2012


On Thu, Apr 12, 2012 at 2:37 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
> If the OP wants to specify different semantics, let's hear it.

Whatever semantics were chosen, they would end up being confusing to *someone*.

With prefix and suffix matching, the implicit OR is simple and
obvious. The same can't be said for the replacement command,
particular if it can be used with unordered collections.

Far better to leave this task to re.sub (which uses regex syntax to
avoid ambiguity) or to explicit flow control and multiple invocations
of replace().

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list