Removing Control characters

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


"Hans Nowak" <wurmy at earthlink.net> wrote in message
news:3E145464.2090802 at earthlink.net...
> Judging from the subject line, you want to remove these control
characters.
...
>    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