
Ivan Pozdeev via Python-Dev writes:
On 22.03.2020 7:46, Steven D'Aprano wrote:
On Sun, Mar 22, 2020 at 06:57:52AM +0300, Ivan Pozdeev via Python-Dev wrote:
Does it need to be separate methods? Yes.
Overloading a single method to do two dissimilar things is poor design.
They are similar. We're removing stuff from an edge in both cases. The only difference is whether input is treated as a character set or as a raw substring.
That is true. However, the rule of thumb (due to Guido, IIRC) is if the parameter is normally going to be a literal constant, and there are few such constants (like <= 3), put them in the name of the function rather than as values for an optional parameter. Overloading doesn't save much, if any, typing in this case. That's why we have strip, rstrip, and lstrip in the first place, although nowadays we'd likely spell the modifiers out (and maybe use start/end rather than left/right, which I would guess force BIDI users to translate to start/end on the fly). Steve