On 2020-03-07 23:01, Cameron Simpson wrote:
On 07Mar2020 08:26, Guido van Rossum <guido@python.org> wrote:
Maybe. FWIW, I looked at what a few other languages offer, and found that in Go, they use Trim(s, chars) for our s.strip(chars), and they have separate TrimPrefix and TrimSuffix methods. That seems the best solution of the bunch, so I am now okay with using stripprefix and stripsuffix. (Why no _? Because startswith and endswith don't have one either.)
I'm somewhat against "strip" in the name, because Python's plain "strip" methods act like PHP and Go trim methods: they strip multiple characters, not fixed strings.
My own preference (and personal library use) is cutprefix and cutsuffix.
Go's Trim strips multiple characters, but, as far as I can tell from the docs, TrimPrefix and TrimSuffix strip a single prefix/suffix string.