[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-02 Thread Glenn Linderman
On 7/2/2019 12:56 PM, Terry Reedy wrote: On 7/2/2019 12:16 AM, Glenn Linderman wrote: On 7/1/2019 8:28 PM, Terry Reedy wrote: I did not read much of the thread, but the proposal is to wrap a near-trivial expression (2 operations) or replace a current method call with a method call than is

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-02 Thread Steve Holden
On Tue, Jul 2, 2019 at 4:24 PM wrote: > It seems to me that the desired behavior here is closest to > 'str.replace()' out of all the options discussed, just with the constraint > of being limited to either the start or the end of the string. (Thus the > .lreplace() and .rreplace() option

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-02 Thread Terry Reedy
On 7/2/2019 12:16 AM, Glenn Linderman wrote: On 7/1/2019 8:28 PM, Terry Reedy wrote: I did not read much of the thread, but the proposal is to wrap a near-trivial expression (2 operations) or replace a current method call with a method call than is more or less the same len as what it

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-02 Thread Steve Dower
On 02Jul2019 0707, brian.sk...@gmail.com wrote: Taking swapping a file extension as an example of a particular transformation of interest, it would be achieved with something like s.replace(".htm", ".html", only_end=True). Please don't use string functions for file system paths, they are not

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-02 Thread brian . skinn
It seems to me that the desired behavior here is closest to 'str.replace()' out of all the options discussed, just with the constraint of being limited to either the start or the end of the string. (Thus the .lreplace() and .rreplace() option suggested by Glenn.) The minimal change (which

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-02 Thread Brian Skinn
s.replace(".htm", ".html", only_end=True). -Brian -- > > Date: Tue, 2 Jul 2019 14:33:57 +1000 > From: Chris Angelico > Subject: [Python-Dev] Re: strip behavior provides inconsistent result

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-01 Thread Chris Angelico
On Tue, Jul 2, 2019 at 2:28 PM Glenn Linderman wrote: > >> A method could raise instead of returning the string as-is if the prefix is >> not really a prefix. How often is this needed? The most common end >> deletions are whitespace, which the current .strip handles correctly. > > raising

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-01 Thread Glenn Linderman
On 7/1/2019 8:28 PM, Terry Reedy wrote: On 7/1/2019 1:57 PM, Chris Barker via Python-Dev wrote: This was quite extensively discussed on python-ideas recently: https://mail.python.org/archives/list/python-id...@python.org/thread/RJARZSUKCXRJIP42Z2YBBAEN5XA7KEC3/#WIRID57ESUFUAQQQ6ZUY2RK5PKQQYSJ3

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-01 Thread Terry Reedy
On 7/1/2019 1:57 PM, Chris Barker via Python-Dev wrote: This was quite extensively discussed on python-ideas recently: https://mail.python.org/archives/list/python-id...@python.org/thread/RJARZSUKCXRJIP42Z2YBBAEN5XA7KEC3/#WIRID57ESUFUAQQQ6ZUY2RK5PKQQYSJ3 The claim of 'inconsistent results' is

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-07-01 Thread Chris Barker via Python-Dev
This was quite extensively discussed on python-ideas recently: https://mail.python.org/archives/list/python-id...@python.org/thread/RJARZSUKCXRJIP42Z2YBBAEN5XA7KEC3/#WIRID57ESUFUAQQQ6ZUY2RK5PKQQYSJ3 (I'm finding it hard to find a good thread view in the new interface -- but that will get you

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-28 Thread Brett Cannon
Glenn Linderman wrote: > On 6/27/2019 3:09 PM, Brett Cannon wrote: > > My guess is that without Guido to just ask this will > > have to go to a PEP as it changes a built-in. > > How does adding two new methods change a built-in? > > Now if an extra parameter were added to modify lstrip, rstrip,

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-28 Thread Glenn Linderman
On 6/28/2019 10:10 AM, MRAB wrote: On 2019-06-28 03:40, Glenn Linderman wrote: On 6/27/2019 3:09 PM, Brett Cannon wrote: My guess is that without Guido to just ask this will have to go to a PEP as it changes a built-in. How does adding two new methods change a built-in? Now if an extra

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-28 Thread MRAB
On 2019-06-28 03:40, Glenn Linderman wrote: On 6/27/2019 3:09 PM, Brett Cannon wrote: My guess is that without Guido to just ask this will have to go to a PEP as it changes a built-in. How does adding two new methods change a built-in? Now if an extra parameter were added to modify lstrip,

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Glenn Linderman
On 6/27/2019 3:09 PM, Brett Cannon wrote: My guess is that without Guido to just ask this will have to go to a PEP as it changes a built-in. How does adding two new methods change a built-in? Now if an extra parameter were added to modify lstrip, rstrip, and strip to make them do something

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Ned Deily
On Jun 27, 2019, at 15:27, Jelle Zijlstra wrote: > El jue., 27 jun. 2019 a las 11:51, escribió: >> excellent and extraordinarily obvious >> >> Thanks for the pointer. >> >> a bit unfortunate that old docs for a module that doesn't seem to exist in >> py3 with less clear but still correct

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Brett Cannon
My guess is that without Guido to just ask this will have to go to a PEP as it changes a built-in. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Jelle Zijlstra
El jue., 27 jun. 2019 a las 11:51, escribió: > excellent and extraordinarily obvious > > Thanks for the pointer. > > a bit unfortunate that old docs for a module that doesn't seem to exist in > py3 with less clear but still correct words is still the top google result > for python string strip.

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread dan
excellent and extraordinarily obvious Thanks for the pointer. a bit unfortunate that old docs for a module that doesn't seem to exist in py3 with less clear but still correct words is still the top google result for python string strip.

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Ethan Furman
On 06/27/2019 07:34 AM, dan@bauman.space wrote: Anyone experienced anything like this? This list is for the development /of/ Python, not development /with/ Python. In the future, please take such questions to, for example, Python List*. -- ~Ethan~ *

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Steven D'Aprano
On Fri, Jun 28, 2019 at 01:08:45AM +1000, Chris Angelico wrote: > Help on built-in function lstrip: [...] > This does NOT remove a leading substring. It removes a set of characters. This is a re-occurring painpoint and gotcha. I've fallen for it myself. I really think it's long past time we

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Calvin Spealman
String strip methods take a set of characters to strip, not a specific string / character sequence. They remove ALL the characters in that set from the left or right until the first character which is not in the set. This can be simply demonstrated here: >>> "foobar".strip("f") 'oobar' >>>

[Python-Dev] Re: strip behavior provides inconsistent results with certain strings

2019-06-27 Thread Chris Angelico
On Fri, Jun 28, 2019 at 1:02 AM wrote: > > Anyone experienced anything like this? > > The behavior seems consistent but unexpected. > > python 3.6 on both windows (10) and linux (ubuntu 18.04) seem to exhibit the > same odd behavior. > > something about a docker-image looking string seems to