python3: removing several chars from a string with a long chain of .replace().replace().replace()
- by MadSc13ntist
I found this example on stack overflow. I understand it, but seems like a bit much for such a simple method concept... removing several chars from a string.
import string
exclude = set(string.punctuation)
s = ''.join(ch for ch in s if ch not in exclude)
is there a builtin string method in python 3.1 to do something to the tune of:
s = "a,b,c,d,e,f,g,h,i"
s = s.strip([",", "d", "h"])
instead of:
s = s.replace(",", "").replace("d", "").replace("h", "")