On 3/24/19 6:45 PM, Cameron Simpson wrote:
Like others I'm against the name 'trim" itself because of PHP's homonym which means what "strip" means in Python (and therefore doesn't mean what "trim" is proposed to mean here). "clip"?
I'm +0.9 rather than +1 entirely because the operation feels so... trivial, which usually trips the "not everything needs a method" argument. But it is also very common.
strip, trim, chop, chomp, clip, left, right, and various permutations with leading "l"s and "r"s. Is the "other" argument a character, a string, or a list of characters, or a list of strings, or a regex? Argh. Maybe I use too many languages and I don't do enough string processing, but I always have to look this stuff up every time I use it, or I just write my own. No, I don't have a solution, but matching or mismatching any particular language only makes sense if you happen to be familiar with that language's string functions. And then someone will fall into a trap because "their" language handles newlines and returns, or spaces and tabs, or some other detail completely differently. That said, I'm all for more library functions, especially in cases like this that are easy to get wrong.