I have a large string with brackets and commas and such. I want to strip all those characters but keep the spacing. How can I do this. As of now I am using
s
The regular-expression based versions might be faster (especially if you switch to using a compiled expression), but I like this for clarity:
"".join([c for c in origList if c in string.letters or c in string.whitespace])
It's a bit weird with the join()
call, but I think that is pretty idiomatic Python for converting a list of characters into a string.