Removing Control characters

Terry Reedy tjreedy at
Thu Jan 2 20:35:18 CET 2003

"Hans Nowak" <wurmy at> wrote in message
news:3E145464.2090802 at
> Judging from the subject line, you want to remove these control
>    data = string.replace(data, chr(8), "")

I believe 2.3 adds an optional param to strip() consisting of a string
of chars to remove.  So the above could then be

data = data.strip(chr(8))

This generalizes to removal of any of multiple chars in a way that
replace does not.  Nice enhancement.

Terry J. Reedy

More information about the Python-list mailing list