On 3/31/19 1:48 AM, Chris Angelico wrote:
If we're bikeshedding the actual method names, I think it would be good to have a list of viable options. A quick skim through the thread gives me these:
* cut_prefix/cut_suffix * strip_prefix/strip_suffix * cut_start/cut_end * Any of the above with the underscore removed * lcut/rcut * ltrim/rtrim (and maybe trim) * truncate (end only, no from-start equivalent)
Of them, I think cutprefix/cutsuffix (no underscore) and lcut/rcut are the strongest contenders, but that's just my opinion. Have I missed anyone's favourite spelling? Is there a name that parallels startswith/endswith?
without_prefix without_suffix They're a little longer, but IMO "without" helps reenforce the immutability of the underlying string. None of these functions actually remove part of the original string, but rather they return a new string that's the original string without some piece of it.