I don't see what trim() is good for but I know I've written ltrim() hundreds of times easy.I propose naming them strip_prefix() and strip_suffix() and just skip the one that does both sides since it makes no sense to me.Trim is generally a bad name because what is called strip() in python is called trim() in other languages. This would be needlessly confusing.Following the discussion here I propose to add 3 new string methods: str.trim, str.ltrim, str.rtrimAnother option would be to change API for str.split method to work correctly with sequences.
In [1]: def ltrim(s, seq):
...: return s[len(seq):] if s.startswith(seq) else s
...:
In [2]: def rtrim(s, seq):
...: return s[:-len(seq)] if s.endswith(seq) else s
...:
In [3]: def trim(s, seq):
...: return ltrim(rtrim(s, seq), seq)
...:
In [5]: ltrim(s, 'mailto:')
In [6]: rtrim(s, 'com')
Out[6]: 'mailto:maria@gmail.'
In [7]: trim(s, 'm')
_______________________________________________Python-ideas mailing listCode of Conduct: http://python.org/psf/codeofconduct/