[Python-ideas] Re: New explicit methods to trim strings

Marco Sulla mail.python.org at marco.sulla.e4ward.com
Sat Mar 7 06:43:02 EST 2020


I agree with Steven D'Aprano.
I never had problems with strip(), but if people find it confusing,
Python can simply leave strip() and all the other function as they are
and add another functions, like crop() or snip() or shear() prune() or
mow(). Personally I prefer crop() or prune().

This way there will be no breaking changes.

On Sat, 7 Mar 2020 at 02:58, Ethan Furman <ethan at stoneleaf.us> wrote:
>
> On 03/06/2020 04:03 PM, Steven D'Aprano wrote:
> > On Thu, Mar 05, 2020 at 12:45:28PM -0800, Andrew Barnert via Python-ideas wrote:
>
> >> Well, I like the idea if someone can come up with a good naming
> >> scheme—something that at least reminds me which function is the “set
> >> of chars” stripper and which the “substring” stripper,
> >
> > You've been a Python programmer for how many years now? Do you currently
> > have trouble remembering what lstrip and rstrip do?
>
> Speaking for myself, about 13 years.  And, yes, I do occasionally forget that the strips are character based.  I can easily imagine it's worse for polyglot programmers.
>
>
> > We already have `[l|r]strip` methods. If we want to associate the new
> > methods with those, I suggest
> >
> >      strip_prefix
> >      strip_suffix
>
> Works for me.  Easy to add to bytes, too, if somebody is so inclined.
>
> --
> ~Ethan~
> _______________________________________________
> Python-ideas mailing list -- python-ideas at python.org
> To unsubscribe send an email to python-ideas-leave at python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/JKBILM3G2C4TQ7XEVIH3V7M7CKCJ4R6Y/
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-list mailing list