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 decryption program I realized I need to strip all the
punctuation, and that's the first thing I came up with. I couldn't
find a built-in function in the time it took to roll my own.

TIA,
Wayne


-- 
To be considered stupid and to be told so is more painful than being
called gluttonous, mendacious, violent, lascivious, lazy, cowardly:
every weakness, every vice, has found its defenders, its rhetoric, its
ennoblement and exaltation, but stupidity hasn't. - Primo Levi
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to