Re: [Python-ideas] for/except/else

2017-03-05 Thread Terry Reedy
On 3/4/2017 10:17 PM, Nick Coghlan wrote: I forget where it came up, but I seem to recall Guido saying that if he were designing Python today, he wouldn't include the "else:" clause on loops, since it inevitably confuses folks the first time they see it. (Hence articles like mine that attempt

Re: [Python-ideas] for/except/else

2017-03-04 Thread Steven D'Aprano
On Sun, Mar 05, 2017 at 01:17:31PM +1000, Nick Coghlan wrote: > I forget where it came up, but I seem to recall Guido saying that if he > were designing Python today, he wouldn't include the "else:" clause on > loops, since it inevitably confuses folks the first time they see it. Heh, if we exclu

Re: [Python-ideas] for/except/else

2017-03-04 Thread Nick Coghlan
On 3 March 2017 at 18:47, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > On 03/03/2017 04:36 AM, Nick Coghlan wrote: > >> On 2 March 2017 at 21:06, Wolfgang Maier >> > > wrote: >> >> - overall I looked at 114 code blocks that

Re: [Python-ideas] for/except/else

2017-03-03 Thread Sven R. Kunze
On 03.03.2017 09:47, Wolfgang Maier wrote: However, the fact that else exists generates a regrettable asymmetry in that there is direct language support for detecting one outcome, but not the other. Stressing the analogy to try/except/else one more time, it's as if "else" wasn't available for

Re: [Python-ideas] for/except/else

2017-03-03 Thread Wolfgang Maier
On 03/03/2017 04:36 AM, Nick Coghlan wrote: On 2 March 2017 at 21:06, Wolfgang Maier mailto:wolfgang.ma...@biologie.uni-freiburg.de>> wrote: - overall I looked at 114 code blocks that contain one or more breaks Thanks for doing that research :) Of the remaining 19 non-trivial case

Re: [Python-ideas] for/except/else

2017-03-03 Thread Wolfgang Maier
On 03/02/2017 07:05 PM, Brett Cannon wrote: - overall I looked at 114 code blocks that contain one or more breaks I wanted to say thanks for taking the time to go through the stdlib and doing such a thorough analysis of the impact of your suggestion! It always helps to have real-world numb

Re: [Python-ideas] for/except/else

2017-03-02 Thread Pavol Lisy
On 3/1/17, Wolfgang Maier wrote: > - as explained by Nick, the existence of "except break" would strengthen > the analogy with try/except/else and help people understand what the > existing else clause after a loop is good for. I was thinking bout this analogy: 1. try/else (without except) is S

Re: [Python-ideas] for/except/else

2017-03-02 Thread Nick Coghlan
On 2 March 2017 at 21:06, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > On 02.03.2017 06:46, Nick Coghlan wrote: > >> The proposal in this thread then has the significant downside of only >> covering the "nested side effect" case: >> >> for item in iterable: >> if

Re: [Python-ideas] for/except/else

2017-03-02 Thread Joao S. O. Bueno
On 1 March 2017 at 06:37, Wolfgang Maier wrote: > Now here's the proposal: allow an except (or except break) clause to follow > for/while loops that will be executed if the loop was terminated by a break > statement. After rethinking over some code I've written in the past, yes, I agree this chan

Re: [Python-ideas] for/except/else

2017-03-02 Thread Brett Cannon
On Thu, 2 Mar 2017 at 03:07 Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: [SNIP] > As always though, reality can be expected to be quite a bit more > complicated than theory so I decided to check the stdlib for real uses > of break. This is quite a tedious task since break is us

Re: [Python-ideas] for/except/else

2017-03-02 Thread Wolfgang Maier
On 02.03.2017 06:46, Nick Coghlan wrote: On 1 March 2017 at 19:37, Wolfgang Maier mailto:wolfgang.ma...@biologie.uni-freiburg.de>> wrote: Now here's the proposal: allow an except (or except break) clause to follow for/while loops that will be executed if the loop was terminated by a

Re: [Python-ideas] for/except/else

2017-03-01 Thread Nick Coghlan
On 1 March 2017 at 19:37, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > I know what the regulars among you will be thinking (time machine, high > bar for language syntax changes, etc.) so let me start by assuring you that > I'm well aware of all of this, that I did research th

Re: [Python-ideas] for/except/else

2017-03-01 Thread Ethan Furman
On 03/01/2017 01:37 AM, Wolfgang Maier wrote: Now here's the proposal: allow an except (or except break) clause to follow for/while loops that will be executed if the loop was terminated by a break statement. I find the proposal interesting. More importantly, the proposal is well written an

Re: [Python-ideas] for/except/else

2017-03-01 Thread Clint Hepner
> On 2017 Mar 1 , at 4:37 a, Wolfgang Maier > wrote: > > I know what the regulars among you will be thinking (time machine, high bar > for language syntax changes, etc.) so let me start by assuring you that I'm > well aware of all of this, that I did research the topic before posting and > t

Re: [Python-ideas] for/except/else

2017-03-01 Thread Wolfgang Maier
On 01.03.2017 12:56, Steven D'Aprano wrote: - How is this implemented? Currently "break" is a simple unconditional GOTO which jumps past the for block. This will need to change to something significantly more complex. one way to implement this with unconditional GOTOs would be (in pseudoc

Re: [Python-ideas] for/except/else

2017-03-01 Thread Wolfgang Maier
On 01.03.2017 12:56, Steven D'Aprano wrote: On Wed, Mar 01, 2017 at 10:37:17AM +0100, Wolfgang Maier wrote: Now here's the proposal: allow an except (or except break) clause to follow for/while loops that will be executed if the loop was terminated by a break statement. Let me see if I unders

Re: [Python-ideas] for/except/else

2017-03-01 Thread Rhodri James
Much snippage; apologies, Wolfgang! On 01/03/17 09:37, Wolfgang Maier wrote: Now here's the proposal: allow an except (or except break) clause to follow for/while loops that will be executed if the loop was terminated by a break statement. [snip] - in some situations for/except/else would make

Re: [Python-ideas] for/except/else

2017-03-01 Thread Steven D'Aprano
On Wed, Mar 01, 2017 at 10:37:17AM +0100, Wolfgang Maier wrote: > Now here's the proposal: allow an except (or except break) clause to > follow for/while loops that will be executed if the loop was terminated > by a break statement. Let me see if I understand the proposal in full. You would all

[Python-ideas] for/except/else

2017-03-01 Thread Wolfgang Maier
I know what the regulars among you will be thinking (time machine, high bar for language syntax changes, etc.) so let me start by assuring you that I'm well aware of all of this, that I did research the topic before posting and that this is not the same as a previous suggestion using almost the