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

2019-03-30 Thread Christopher Barker
On Fri, Mar 29, 2019 at 6:38 PM Steven D'Aprano wrote: > On Fri, Mar 29, 2019 at 04:05:55PM -0700, Christopher Barker wrote: > > > This proposal would provide a minor gain for an even more minor > disruption. > > I don't think that is correct. I think you are underestimating the gain > and exagge

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

2019-03-30 Thread Steven D'Aprano
On Sat, Mar 30, 2019 at 12:15:00AM -0700, Christopher Barker wrote: > On Fri, Mar 29, 2019 at 6:38 PM Steven D'Aprano wrote: > > > On Fri, Mar 29, 2019 at 04:05:55PM -0700, Christopher Barker wrote: > > > > > This proposal would provide a minor gain for an even more minor > > disruption. > > > >

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

2019-03-30 Thread Paul Moore
On Fri, 29 Mar 2019 at 23:07, Christopher Barker wrote: > The proposal at hand is to add two fairly straightforward methods to string. > So: Some of what you are calling digressions are actually questioning the design choice behind that proposal. Specifically, there's no particular justification

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-30 Thread Paul Moore
On Sat, 30 Mar 2019 at 10:29, Alex Grigoryev wrote: > 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. > As someone who was programming 28 yea

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

2019-03-30 Thread Steven D'Aprano
On Fri, Mar 29, 2019 at 12:06:25PM +0900, Stephen J. Turnbull wrote: > Anders Hovmöller writes: [...] > > just like always. This seems totally irrelevant to the > > discussion. And it's of course irrelevant to all the end users that > > aren't writing libraries but are using python directly. >

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

2019-03-30 Thread Anders Hovmöller
> On 30 Mar 2019, at 11:21, Paul Moore > > Note that the proposed name (trim) is IMO "poorly named", because a > number of languages in my experience use that name for what Python > calls "strip", so there would be continual confusion (for me at least) > over which name meant which behaviour..

Re: [Python-ideas] Unified style of cache management API

2019-03-30 Thread Serhiy Storchaka
29.03.19 20:52, Brett Cannon пише: On Thu, Mar 28, 2019 at 10:53 AM Serhiy Storchaka > wrote: 28.03.19 19:45, Brett Cannon пише: > So I would say that a cache-clearing function convention would be a > reasonable starting point. If that turns out to not

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

2019-03-30 Thread Steven D'Aprano
On Sat, Mar 30, 2019 at 10:21:23AM +, Paul Moore wrote: > On Fri, 29 Mar 2019 at 23:07, Christopher Barker wrote: > > The proposal at hand is to add two fairly straightforward methods to > > string. So: > > Some of what you are calling digressions are actually questioning the > design choice

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

2019-03-30 Thread Steven D'Aprano
On Sat, Mar 30, 2019 at 11:40:18AM +, Paul Moore wrote: > Is str.trim like str.swapcase, or like str.split? Who knows, at this point? I think you are making a rhetorical point, but not a very good one. I think we all know, or at least *should* know, that this proposal is much closer to spli

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

2019-03-30 Thread David Mertz
On Sat, Mar 30, 2019, 8:42 AM Steven D'Aprano wrote: > Most of us have had to cut a prefix or a suffix from a string, often a > file extension. Its not as common as, say, stripping whitespace, but it > happens often enough. I do this all the time! I never really thought about wanting a method t

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

2019-03-30 Thread Dan Sommers
On 3/30/19 9:03 AM, David Mertz wrote: On Sat, Mar 30, 2019, 8:42 AM Steven D'Aprano wrote: Most of us have had to cut a prefix or a suffix from a string, often a file extension. Its not as common as, say, stripping whitespace, but it happens often enough. I do this all the time! I never re

Re: [Python-ideas] New Project to Capture summaries from this

2019-03-30 Thread Brett Cannon
I think this thread has gone off-topic as this mailing list is not about Gmail (the client or the service). ;) On Fri, Mar 29, 2019 at 4:21 AM Chris Angelico wrote: > On Fri, Mar 29, 2019 at 8:41 PM Steven D'Aprano > wrote: > > On Fri, Mar 29, 2019 at 02:23:52PM +1100, Chris Angelico wrote: > >

[Python-ideas] Built-in parsing library

2019-03-30 Thread Nam Nguyen
Hello list, What do you think of a universal parsing library in the stdlib mainly for use by other libraries in the stdlib? Through out the years we have had many issues with protocol parsing. Some have even introduced security bugs. The main cause of these issues is the use of simple regular exp

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

2019-03-30 Thread Stephen J. Turnbull
Anders Hovmöller writes: > That isn't the proposal as it stands now. The consensus among those > supporting the idea is "strip_prefix" and "strip_suffix". Let's > debate that. IMO, the "prefix" and "suffix" parts are necessary to fully clarify the intent (and do that well), so any of the verbs

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

2019-03-30 Thread Stephen J. Turnbull
Steven D'Aprano writes: > The correct solution is a verbose statement: > > if string.startswith("spam"): > string = string[:len("spam")] This is harder to write than I thought! (The slice should be 'len("spam"):'.) But s/The/A/: string = re.sub("^spam", "", string) And a

Re: [Python-ideas] New Project to Capture summaries from this

2019-03-30 Thread Stephen J. Turnbull
Chris Angelico writes: > Have you ever actually convinced someone to move off Gmail onto > some other client? No, but then, I never tried. I have gotten a couple score people to seriously try about a dozen different MUAs over the last three decades though. It's not impossible. But that's rea

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

2019-03-30 Thread MRAB
On 2019-03-30 13:03, David Mertz wrote: On Sat, Mar 30, 2019, 8:42 AM Steven D'Aprano > wrote: Most of us have had to cut a prefix or a suffix from a string, often a file extension. Its not as common as, say, stripping whitespace, but it happens often enou

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

2019-03-30 Thread Brandt Bucher
> One thing I love about .startswith() and .endswith() is matching multiple > options. It's a little funny the multiple options must be a tuple exactly > (not a list, not a set, not an iterator), but whatever. It would be about to > lack that symmetry in the .cut_suffix() method. > > E.g now:

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

2019-03-30 Thread David Mertz
I like this idea quite a lot. I do not think of anything it works best at first consideration. On Sat, Mar 30, 2019, 8:28 PM Brandt Bucher wrote: > > > One thing I love about .startswith() and .endswith() is matching > multiple options. It's a little funny the multiple options must be a tuple >

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

2019-03-30 Thread Steven D'Aprano
On Sun, Mar 31, 2019 at 03:05:59AM +0900, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > > The correct solution is a verbose statement: > > > > if string.startswith("spam"): > > string = string[:len("spam")] > > This is harder to write than I thought! (The slice should

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

2019-03-30 Thread Chris Angelico
On Sun, Mar 31, 2019 at 3:44 PM Steven D'Aprano wrote: > Of course it doesn't help if you come to Python from a language where > strip() deletes a prefix or suffix, but even if you don't, as I don't, > there's something about the pattern: > > string = string.lstrip("spam") > > which looks like

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

2019-03-30 Thread Anders Hovmöller
> Steven D'Aprano: > > Stephen J. Turnbull: > >> And the bikeshedding isn't hard. In the list above, cutprefix/ >> cutsuffix are far and away the best. > > Well I'm glad we agree on that, even if nothing else :-) I prefer “strip_prefix” because of the analogy to strip() which doesn’t do any