On Tue, Oct 25, 2016 at 4:48 AM, Chris Barker <chris.barker@noaa.gov> wrote:
> On Mon, Oct 24, 2016 at 8:21 AM, Michel Desmoulin
> <desmoulinmichel@gmail.com> wrote:
>>
>> This actually could be implemented directly in str.replace() without
>> breaking the API by accepting:
>>
>> "stuff".replace('a', '')
>> "stuff".replace(('a', 'b', 'c'), '')
>> "stuff".replace(('a', 'b', 'c'), ('?', '*', ''))
>
>
> +1 -- I have found I Need to do this often enough that I've wondered why
> it's not there.
>
> making three calls to replace() isn't too bad, but is klunky and has
> performance issues.
And it may not be semantically identical. In the examples above, three
separate replace calls would work, but a syntax like this ought to be
capable of an exchange - "aabbccdd".replace(('b', 'd'), ('d', 'b')) ==
"aaddccbb".
ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/