31 Mar
2019
31 Mar
'19
5:53 a.m.
Steven D'Aprano:
Stephen J. Turnbull:
And the bikeshedding isn't hard. In the list above, cutprefix/ cutsuffix are far and away the best.
Well I'm glad we agree on that, even if nothing else :-)
I prefer “strip_prefix” because of the analogy to strip() which doesn’t do anything if the characters aren’t present. Introducing a new word “cut” seems unnecessary and confusing and I’d wager it will increase the probability of: if s.startswith(‘foo’): s = s.cutprefix(‘foo’) Obviously this is a guess! I also don’t understand why not using the underscore is preferable? It seems just to be poor form. / Anders