Deleting characters from a string

Hrvoje Niksic hniksic at
Sat Jun 5 14:30:40 EDT 1999

"Tim Peters" <tim_one at> writes:

> It's (yours, not mine ...) a decent idea; in the meantime how about
> writing a little wrapper
> def deletechars(s, todelete, id=string.maketrans('', '')):
>     return string.translate(s, id, todelete)

I think I'd rather write a patch that allows None as the second
argument to string.translate(), if that's OK with the developers.

Thanks for the tip, though.

More information about the Python-list mailing list