June 27, 2019
5:33 p.m.
On Fri, Jun 28, 2019 at 01:08:45AM +1000, Chris Angelico wrote:
Help on built-in function lstrip: [...] This does NOT remove a leading substring. It removes a set of characters.
This is a re-occurring painpoint and gotcha. I've fallen for it myself. I really think it's long past time we bite the bullet and add a pair of methods to strip a prefix and suffix from strings. My preferred bikeshed colour would be strip_prefix and strip_suffix. Will this need a PEP? -- Steven