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

2019-04-02 Thread Alex Grigoryev
In your case you probably should use [model.split(".")[1] for model in models] strip_prefix should not be used with file extensions, method for files already exist. On Apr 2 2019, at 5:43 am, David Mertz wrote: > On Mon, Apr 1, 2019 at 8:54 PM Steven D'Aprano (mailto:st...@pearwood.info)> wrote

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

2019-03-31 Thread Alex Grigoryev
That's why strip_prefix(suffix) is a better name, can't double think. On март 31 2019, at 11:56 утра, Steven D'Aprano wrote: > On Sun, Mar 31, 2019 at 07:35:22PM +1100, Steven D'Aprano wrote: > > > "musical".lcut(('al', 'ical')) > Oops, typo, I was thinking rcut and wrote lcut :-( > -- > Steven >

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

2019-03-30 Thread Alex Grigoryev
To me this is really surprising that 28 years old language has some weird methods like str.swapcase(), but none to cut string from left or right, and two of them which exist only accept string mask. On март 30 2019, at 12:21 дня, Paul Moore wrote: > On Fri, 29 Mar 2019 at 23:07, Christopher Bar

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

2019-03-25 Thread Alex Grigoryev
strip_prefix and strip_suffix I think are the best names from all and work perfectly with auto completion. Common use case: " mailto:ma...@gmail.com".strip().strip_prefix("mailto:";) On Mar 25 2019, at 4:40 pm, Anders Hovmöller wrote: > > > Earlier, Anders wrote: > > I propose naming them strip_

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

2019-03-24 Thread Alex Grigoryev
me because what is called strip() in python is > called trim() in other languages. This would be needlessly confusing. > > On 24 Mar 2019, at 09:42, Alex Grigoryev (https://link.getmailspring.com/link/5181b0db-3b10-4202-90d6-1365aef19...@getmailspring.com/0?r

[Python-ideas] New explicit methods to trim strings

2019-03-24 Thread Alex Grigoryev
Following the discussion here (https://link.getmailspring.com/link/7d84d131-65b6-4ef7-9c43-51957f9df...@getmailspring.com/0?redirect=https%3A%2F%2Fbugs.python.org%2Fissue36410&recipient=cHl0aG9uLWlkZWFzQHB5dGhvbi5vcmc%3D) I propose to add 3 new string methods: str.trim, str.ltrim, str.rtrim Anoth