Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Peter Otten
Terry Reedy wrote: Cédric Lucantis wrote: I don't see any string method to do that 'abcde'.translate(str.maketrans('','','bcd')) 'ae' I do not claim this to be better than all the other methods, but this pair can also translate while deleting, which others cannot. You should

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Peter Otten [EMAIL PROTECTED] wrote: Terry Reedy wrote: 'abcde'.translate(str.maketrans('','','bcd')) 'ae' You should mention that you are using Python 3.0 ;) The 2.5 equivalent would be uabcde.translate(dict.fromkeys(map(ord, ubcd))) u'ae' Only if you're

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Peter Otten
Sion Arrowsmith wrote: In article [EMAIL PROTECTED], Peter Otten [EMAIL PROTECTED] wrote: Terry Reedy wrote: 'abcde'.translate(str.maketrans('','','bcd')) 'ae' You should mention that you are using Python 3.0 ;) The 2.5 equivalent would be uabcde.translate(dict.fromkeys(map(ord, ubcd)))

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Terry Reedy
Peter Otten wrote: Terry Reedy wrote: Cédric Lucantis wrote: I don't see any string method to do that 'abcde'.translate(str.maketrans('','','bcd')) 'ae' I do not claim this to be better than all the other methods, but this pair can also translate while deleting, which others cannot.

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Ethan Furman
Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip -- 'www.example.com'.strip('cmowz.') 'example'

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-17 Thread Roel Schroeven
Peter Otten schreef: Ethan Furman wrote: The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) identity = .join(map(chr, range(256))) Or identity =

'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Ethan Furman
Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip -- 'www.example.com'.strip('cmowz.') 'example' .??? -- ---

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Calvin Spealman
On Jun 16, 2008, at 12:58 PM, Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Cédric Lucantis
Hi, Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip -- 'www.example.com'.strip('cmowz.') 'example' .??? --

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Larry Bates
Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip -- 'www.example.com'.strip('cmowz.') 'example'

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Maric Michaud
Le Monday 16 June 2008 18:58:06 Ethan Furman, vous avez écrit : The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Peter Otten
Ethan Furman wrote: The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) identity = .join(map(chr, range(256))) 'www.example.com'.translate(identity,

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Raymond Hettinger
On Jun 16, 10:09 am, Peter Otten [EMAIL PROTECTED] wrote: Ethan Furman wrote: The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) identity =

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Terry Reedy
Cédric Lucantis wrote: I don't see any string method to do that 'abcde'.translate(str.maketrans('','','bcd')) 'ae' I do not claim this to be better than all the other methods, but this pair can also translate while deleting, which others cannot. --