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

Gregory P. Smith greg at krypto.org
Fri Apr 13 02:40:01 CEST 2012

On Wed, Apr 11, 2012 at 9:56 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> 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().
Agreed.  Which is why I'm -1 on the proposed change to str.replace().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120412/7976e99e/attachment.html>

More information about the Python-ideas mailing list