[Python-ideas] New explicit methods to trim strings
steve at pearwood.info
Sun Mar 31 20:08:37 EDT 2019
Thank you, this is a simple, unambiguous proposal which meets a real need
and will help prevent a lot of wasted developer time misusing [lr]strip
and then reporting it as a bug: remove a single prefix or suffix.
This is a useful string primitive provided by other modern languages and
libraries, including Go, Ruby, Kotlin, and the Apache StringUtils Java
Regarding later proposals to add support for multiple affixes, to
recursively delete the affix repeatedly, and to take an additional
argument to limit how many affixes will be removed: YAGNI.
Let's not over-engineer this to be something which is ambigious and
complex. We can add more complexity later, if and when practical
(1) that multiple affixes actually is useful in practice, not just a
"Wouldn't It Be Cool???" feature; and
(2) a consensus as to how to handle ambiguous cases.
Until then, let's keep it simple: methods to remove a *single* prefix or
suffix, precisely as given. Anything else is YAGNI and is best left for
the individual programmer.
More information about the Python-ideas