Re: [Tutor] Stripping punctuation

2008-05-29 Thread Alan Gauld
"W W" <[EMAIL PROTECTED]> wrote Is there a faster way to strip punctuation from a string than this? Yes from string import ascii_letters def strip_punctuation(mystring): newstring = '' for x in mystring: if x in ascii_letters: newstring += x This is very slow sinc

Re: [Tutor] Stripping punctuation

2008-05-29 Thread Kent Johnson
On Thu, May 29, 2008 at 1:35 PM, W W <[EMAIL PROTECTED]> wrote: > Is there a faster way to strip punctuation from a string than this? def strip_punctuation(my_string): return ''.join(c for c in my_string if c in ascii_letters) or use str.translate(): http://docs.python.org/lib/string-methods.ht

[Tutor] Stripping punctuation

2008-05-29 Thread W W
Is there a faster way to strip punctuation from a string than this? from string import ascii_letters def strip_punctuation(mystring): newstring = '' for x in mystring: if x in ascii_letters: newstring += x else: pass return newstring In my decr