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

2019-04-01 Thread David Mertz
On Mon, Apr 1, 2019 at 8:54 PM Steven D'Aprano wrote: > I can think of at least one English suffix pair that clash: -ify, -fy. > How about other languages? How comfortable are you to say that nobody > doing text processing in German or Hindi will need to deal with clashing > affixes? > Here

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

2019-04-01 Thread David Mertz
On Mon, Apr 1, 2019 at 10:11 PM Dan Sommers < 2qdxy4rzwzuui...@potatochowder.com> wrote: > So I've seen someone (likely David Mertz?) ask for something > like filename.strip_suffix(('.png', '.jpg')). What is the > context? Is it strictly a filename processing program? Do > you subsequently

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

2019-04-01 Thread Steven D'Aprano
On Mon, Apr 01, 2019 at 09:34:21PM -0400, David Mertz wrote: > On Mon, Apr 1, 2019, 8:54 PM Steven D'Aprano wrote: > > > The point I am making is not that we must not ever support multiple > > affixes, but that we shouldn't rush that decision. Let's pick the > > low-hanging fruit, and get some

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

2019-04-01 Thread Dan Sommers
On 4/1/19 9:34 PM, David Mertz wrote: On Mon, Apr 1, 2019, 8:54 PM Steven D'Aprano wrote: The point I am making is not that we must not ever support multiple affixes, but that we shouldn't rush that decision. Let's pick the low-hanging fruit, and get some real-world experience with the

[Python-ideas] Lessons learned from an API design mistake [was New explicit methods to trim strings]

2019-04-01 Thread Steven D'Aprano
I think the point Chris made about statistics.mode is important enough to start a new subthread about API design, and the lessons learned. On Mon, Apr 01, 2019 at 02:29:44PM +1100, Chris Angelico wrote: > We're basically debating collision semantics here. It's on par with > asking "how should

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

2019-04-01 Thread Chris Angelico
On Tue, Apr 2, 2019 at 11:53 AM Steven D'Aprano wrote: > The point I am making is not that we must not ever support multiple > affixes, but that we shouldn't rush that decision. Let's pick the > low-hanging fruit, and get some real-world experience with the function > before deciding how to

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

2019-04-01 Thread Steven D'Aprano
On Mon, Apr 01, 2019 at 02:29:44PM +1100, Chris Angelico wrote: > The multiple affix case has exactly two forms: > > 1) Tearing multiple affixes off (eg stripping "asdf.jpg.png" down to > just "asdf"), which most people are saying "no, don't do that, it > doesn't make sense and isn't needed"

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Chris Angelico
On Tue, Apr 2, 2019 at 9:34 AM Jonathan Goble wrote: > > On Mon, Apr 1, 2019 at 6:12 PM Greg Ewing wrote: >> >> Obviously, removing a whole day from the year will create problems >> keeping the calendar in step with the seasons. To compensate, it >> will be necessary to add approximately 1.25

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Jonathan Goble
On Mon, Apr 1, 2019 at 6:12 PM Greg Ewing wrote: > Obviously, removing a whole day from the year will create problems > keeping the calendar in step with the seasons. To compensate, it > will be necessary to add approximately 1.25 days worth of leap > seconds to each year. This works out to

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Cameron Simpson
On 02Apr2019 10:43, Greg Ewing wrote: Paul Moore wrote: now that Python has type inference, it should be possible for users to just type {} and have the interpreter work out which was intended from context. Or have {} return an ambiguous object that turns into a dict or set depending on what

Re: [Python-ideas] Built-in parsing library

2019-04-01 Thread Terry Reedy
On 4/1/2019 1:14 AM, Guido van Rossum wrote: We do have a parser generator in the standard library: https://github.com/python/cpython/tree/master/Lib/lib2to3/pgen2 It is effectively undocumented and by inference discouraged from use. The entry for lib2to3 in the 2to3 doc:

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Greg Ewing
Anders Hovmöller wrote: Please let's all agree that April 1 is the worst day of the year. Agreed. In light of that, I propose that the datetime module in Python 4 be changed so that April 1 does not exist: >>> m31 = date(2019, 3, 31) >>> m31 + timedelta(days = 1) datetime.date(2019, 4, 2)

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Greg Ewing
Paul Moore wrote: now that Python has type inference, it should be possible for users to just type {} and have the interpreter work out which was intended from context. Or have {} return an ambiguous object that turns into a dict or set depending on what is done to it. We could call it a

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Dan Sommers
On 4/1/19 11:35 AM, Anders Hovmöller wrote: Please let's all agree that April 1 is the worst day of the year. I can't reproduce your problem. What version of Python are you running, and on what OS? Please show us your program, and tell us what you expected it to do and what it did that

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Adrien Ricocotam
Am I being fooled ? I guess yes That’s the worst idea I ever heard. Python is supposed to be easy to use, don’t change it into Rust ! On Mon 1 Apr 2019 at 22:06, Jelle Zijlstra wrote: > > > El lun., 1 abr. 2019 a las 7:28, Antoine Pietri (< > antoine.piet...@gmail.com>) escribió: > >> While

Re: [Python-ideas] Built-in parsing library

2019-04-01 Thread Nam Nguyen
Sure! Same examples mentioned in Victor's https://vstinner.github.io/tag/security.html could have been fixed by having a more proper parser. This one that I helped author was also a parsing issue. https://python-security.readthedocs.io/vuln/bpo-30500_urllib_connects_to_a_wrong_host.html Thanks

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Jelle Zijlstra
El lun., 1 abr. 2019 a las 7:28, Antoine Pietri () escribió: > While the switch to Python 3 did an excellent job in removing some of > the old inconsistencies we had in the language, pretty much everyone > agrees that some other backwards-incompatible changes could be made to > remove some old

Re: [Python-ideas] Built-in parsing library

2019-04-01 Thread Nathaniel Smith
On Sun, Mar 31, 2019 at 9:17 PM Nam Nguyen wrote: > Installing a package out of stdlib does not solve the problem that motivated > this thread. The libraries included in the stdlib can't use those parsers. Can you be more specific about exactly which code in the stdlib you think should be

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread MRAB
On 2019-04-01 19:33, Paul Moore wrote: On Mon, 1 Apr 2019 at 16:36, Anders Hovmöller wrote: Please let's all agree that April 1 is the worst day of the year. Maybe in Python 4, datetime.datetime should silently convert 1st April to the 2nd? :-P Converting silently is not Pythonic. It

Re: [Python-ideas] PEP-582 and multiple Python versions

2019-04-01 Thread Brett Cannon
I just wanted to warn people that I don't know if any of the authors of PEP 582 subscribe to python-ideas and they have not brought it forward for discussion yet, so there's no guarantee of a response. On Mon, Apr 1, 2019 at 5:27 AM Calvin Spealman wrote: > While the PEP does show the version

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Paul Moore
On Mon, 1 Apr 2019 at 16:36, Anders Hovmöller wrote: > > Please let's all agree that April 1 is the worst day of the year. Maybe in Python 4, datetime.datetime should silently convert 1st April to the 2nd? :-P Paul ___ Python-ideas mailing list

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Anders Hovmöller
Please let's all agree that April 1 is the worst day of the year. > On 1 Apr 2019, at 16:27, Antoine Pietri wrote: > > While the switch to Python 3 did an excellent job in removing some of > the old inconsistencies we had in the language, pretty much everyone > agrees that some other

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Paul Moore
On Mon, 1 Apr 2019 at 15:59, Todd wrote: > Currently there is no empty set literal. This is a hold-over from when there > were no sets. Now would be a good opportunity to add one. I suggest {} > become an empty set and {:} be an empty dict. There should be no need for two styles - now that

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Todd
On Mon, Apr 1, 2019, 10:28 Antoine Pietri wrote: > While the switch to Python 3 did an excellent job in removing some of > the old inconsistencies we had in the language, pretty much everyone > agrees that some other backwards-incompatible changes could be made to > remove some old warts and

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Eric Fahlgren
On Mon, Apr 1, 2019 at 7:50 AM Antoine Pitrou wrote: > > And 01 / 04 / 2019 should return a April 1st datetime. > > (except in the US, of course) > Where it would of course be I / / MMXV, unless you have ISO-8601 set in which case it would be MMXV - - I

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Antoine Pitrou
On Mon, 1 Apr 2019 10:41:40 -0400 Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 4/1/19 10:27 AM, Antoine Pietri wrote: > > > - The / operator returns floats, which loses information when both of > > the operands are integer. In Python 4, “1 / 2” should return a > > decimal.Decimal.

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Dan Sommers
On 4/1/19 10:27 AM, Antoine Pietri wrote: - The / operator returns floats, which loses information when both of the operands are integer. In Python 4, “1 / 2” should return a decimal.Decimal. To ease the transition, we propose to add a new “from __future__ import decimal_division” in Python 3.9

Re: [Python-ideas] Built-in parsing library

2019-04-01 Thread Stephen J. Turnbull
David Mertz writes: > OK, I'll acknowledge my comment might have overstated the bar to overcome. > A parser added to the standard library doesn't need to be perfect for > everyone. But adding to stdlib *does* provide a kind of endorsement of the > right default way to go about things.

[Python-ideas] PEP-582 and multiple Python versions

2019-04-01 Thread Calvin Spealman
While the PEP does show the version number as part of the path to the actual packages, implying support for multiple versions, this doesn't seem to be spelled out in the actual text. Presumably __pypackages__/3.8/ might sit beside __pypackages__/3.9/, etc. to keep future versions capable of

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

2019-04-01 Thread Paul Moore
On Mon, 1 Apr 2019 at 01:01, Steven D'Aprano wrote: > > On Mon, Apr 01, 2019 at 12:02:25PM +1300, Greg Ewing wrote: > > Dan Sommers wrote: > > > > >without_prefix > > >without_suffix > > > > > >They're a little longer, but IMO "without" helps > > >reenforce the immutability of the underlying

Re: [Python-ideas] Built-in parsing library

2019-04-01 Thread Stephen J. Turnbull
David Mertz writes: > While I can imagine proposing one for inclusion in the standard > library, you'd have to choose one (or write a new one) and explain > why that one is better for everyone (or at least a better starting > point) than all the others are. In principle, no, one just needs

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

2019-04-01 Thread Stephen J. Turnbull
On 3/31/19 1:48 AM, Chris Angelico wrote: > > * strip_prefix/strip_suffix I don't like "strip" because .strip already has a different meaning, although the inclusion of prefix/suffix makes the intended sematics clear enough for the new methods. I wonder if it might make the semantics of .strip