Re: [Tutor] Remove specific chars from a string

2008-04-16 Thread python
Ricardo, Thanks for the tip on how to use maketrans. I was trying to over-complicate things on my side. The string module lives in 3.0 ... only the duplicate methods have been removed. Regards, Malcolm ___ Tutor maillist - Tutor@python.org http://mai

Re: [Tutor] Remove specific chars from a string

2008-04-15 Thread John Fouhy
On 16/04/2008, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > You just have to use maketrans with empty strings. If string is > deprecated then I guess some other way of creating translation tables > will be provided. Most string.* functions are deprecated, because they've been moved to methods of

Re: [Tutor] Remove specific chars from a string

2008-04-15 Thread Ricardo Aráoz
> Malcolm Greene wrote: >> What is the Pythonic way to remove specific chars from a string? The >> .translate( table[, deletechars]) method seems the most 'politically >> correct' and also the most complicated. Why complicated? import string myStr = 'some text from which you want to delete some

Re: [Tutor] Remove specific chars from a string

2008-04-14 Thread Dick Moores
At 01:39 PM 4/14/2008, Kent Johnson wrote: Dick Moores wrote: def sigDigits(n):     """     Strips any real decimal (as string) to just its significant digits,     then returns its length, the number of significant digits.     Examples: "-345" -> "345" -> 3;     "3.000" -> "3000" -> 4     "0.0001

Re: [Tutor] Remove specific chars from a string

2008-04-14 Thread Kent Johnson
Dick Moores wrote: > def sigDigits(n): > """ > Strips any real decimal (as string) to just its significant digits, > then returns its length, the number of significant digits. > Examples: "-345" -> "345" -> 3; > "3.000" -> "3000" -> 4 > "0.0001234" -> "1234" -> 4; > "10.

Re: [Tutor] Remove specific chars from a string

2008-04-14 Thread Dick Moores
At 12:04 PM 4/14/2008, Kent Johnson wrote: Malcolm Greene wrote: > What is the Pythonic way to remove specific chars from a string? The > .translate( table[, deletechars]) method seems the most 'politically > correct' and also the most complicated. Most 'correct' and also by far the fastest. This

Re: [Tutor] Remove specific chars from a string

2008-04-14 Thread Alan Gauld
"Malcolm Greene" <[EMAIL PROTECTED]> wrote > What is the Pythonic way to remove specific chars from a string? The > .translate( table[, deletechars]) method seems the most 'politically > correct' and also the most complicated. Assuming you have lots of different characters and not just one to re

Re: [Tutor] Remove specific chars from a string

2008-04-14 Thread Kent Johnson
Malcolm Greene wrote: > What is the Pythonic way to remove specific chars from a string? The > .translate( table[, deletechars]) method seems the most 'politically > correct' and also the most complicated. Most 'correct' and also by far the fastest. This recipe makes it a bit easier to use: http: