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
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/56MCGZR4AHLCG6UWV5TOEYH2PNS52SNO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to