Re: [Python-ideas] Easily remove characters from a string.

2016-10-25 Thread Sjoerd Job Postmus
On Mon, Oct 24, 2016 at 05:37:29PM -0700, Chris Barker - NOAA Federal wrote: > > On Oct 24, 2016, at 3:54 PM, Chris Angelico wrote: > > > . But in any case, > > this is a question you can't even ask until replace() accepts multiple > > arguments. Hence I'm +1 on the notion of simultaneous replace

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Chris Barker - NOAA Federal
> On Oct 24, 2016, at 3:54 PM, Chris Angelico wrote: > . But in any case, > this is a question you can't even ask until replace() accepts multiple > arguments. Hence I'm +1 on the notion of simultaneous replacements > being supported. Agreed -- there are a lot of edge cases to work out, and ther

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Chris Angelico
On Tue, Oct 25, 2016 at 9:11 AM, Nathan Schneider wrote: > What would be the expected behavior of "aabbccdd".replace(('a', 'aa'), ('x', > 'y'))? It's not obvious to me whether longer replacement strings ('aa') or > earlier replacement strings ('a') should take priority. I'm actually not sure, so

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Nathan Schneider
On Mon, Oct 24, 2016 at 5:56 PM, Chris Angelico wrote: > On Tue, Oct 25, 2016 at 4:48 AM, Chris Barker > wrote: > > On Mon, Oct 24, 2016 at 8:21 AM, Michel Desmoulin > > wrote: > >> > >> This actually could be implemented directly in str.replace() without > >> breaking the API by accepting: > >

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Chris Angelico
On Tue, Oct 25, 2016 at 4:48 AM, Chris Barker wrote: > On Mon, Oct 24, 2016 at 8:21 AM, Michel Desmoulin > wrote: >> >> This actually could be implemented directly in str.replace() without >> breaking the API by accepting: >> >> "stuff".replace('a', '') >> "stuff".replace(('a', 'b', 'c'), '') >>

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Chris Barker
On Mon, Oct 24, 2016 at 8:21 AM, Michel Desmoulin 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 f

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Michel Desmoulin
Le 22/10/2016 à 10:34, Simon Mark Holland a écrit : Having researched this as heavily as I am capable with limited experience, I would like to suggest a Python 3 equivalent to string.translate() that doesn't require a table as input. Maybe in the form of str.stripall() or str.replaceall(). My

Re: [Python-ideas] Easily remove characters from a string.

2016-10-23 Thread Steven D'Aprano
On Sat, Oct 22, 2016 at 03:34:23PM +0700, Simon Mark Holland wrote: > Having researched this as heavily as I am capable with limited experience, > I would like to suggest a Python 3 equivalent to string.translate() that > doesn't require a table as input. Maybe in the form of str.stripall() or > s

Re: [Python-ideas] Easily remove characters from a string.

2016-10-23 Thread M.-A. Lemburg
On 22.10.2016 10:34, Simon Mark Holland wrote: > Having researched this as heavily as I am capable with limited experience, > I would like to suggest a Python 3 equivalent to string.translate() that > doesn't require a table as input. Maybe in the form of str.stripall() or > str.replaceall(). > >

Re: [Python-ideas] Easily remove characters from a string.

2016-10-22 Thread Simon Mark Holland
Understood, and I agree, I have seen someone make a similar argument for using RegEx. Here are my main points... 1) Speed - Built-in's are faster. 2) Standardisation - It is a common task, that has MANY ways of being completed. 3) Frequent Task - It is to my mind as useful as str.strip() or str.r

Re: [Python-ideas] Easily remove characters from a string.

2016-10-22 Thread David B
I would use list comprehension even if there were some other way to translate as it is straight forward. On 10/22/16, Simon Mark Holland wrote: > Having researched this as heavily as I am capable with limited experience, > I would like to suggest a Python 3 equivalent to string.translate() that >

[Python-ideas] Easily remove characters from a string.

2016-10-22 Thread Simon Mark Holland
Having researched this as heavily as I am capable with limited experience, I would like to suggest a Python 3 equivalent to string.translate() that doesn't require a table as input. Maybe in the form of str.stripall() or str.replaceall(). My reasoning is that while it is currently possible to eas