'string'.strip(chars)-like function that removes from the middle?

Terry Reedy tjreedy at udel.edu
Tue Jun 17 02:13:19 CEST 2008



Cédric Lucantis wrote:

> I don't see any string method to do that

 >>> 'abcde'.translate(str.maketrans('','','bcd'))
'ae'

I do not claim this to be better than all the other methods,
but this pair can also translate while deleting, which others cannot.




More information about the Python-list mailing list