On 2019-06-28 03:40, Glenn Linderman wrote:
On 6/27/2019 3:09 PM, Brett Cannon wrote:
My guess is that without Guido to just ask this will have to go to a PEP as it changes a built-in.
How does adding two new methods change a built-in?
Now if an extra parameter were added to modify lstrip, rstrip, and strip to make them do something different, yes.
But adding new methods doesn't change anything, unless someone is checking for their existence.
My preferred color is pstrip and sstrip (prefix and suffix strip) since lstrip and rstrip mean left and right.
And maybe there should be a psstrip, that takes two parameters, the prefix and the suffix to strip.
Such functions would certainly reduce code in a lot of places where I do
if string.startswith('foo'): string = string[ 3: ];
as well as making it more robust, because the string and its length have to stay synchronized when changes are made.
lstrip and rstrip remove treat the argument as a set of characters and can remove multiple characters, so having additional methods pstrip and sstrip with their very similar names but different behaviours could be confusing.
I'd prefer to stick with lXXX and rXXX. ldrop and rdrop, maybe?