Re: [Python-ideas] For/in/as syntax

2017-03-04 Thread Erik
Hi Brice, On 04/03/17 08:45, Brice PARENT wrote: * Creating a real object at runtime for each loop which needs to be the target of a non-inner break or continue However, I'm not sure the object should be constructed and fed for every loop usage. It should probably only be instanciated if expl

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Erik
On 03/03/17 19:02, Alexandre Brault wrote: I believe what Matthias is hoping for is an equivalent of Java's named break feature. Breaking out of an outer loop implicitly breaks out of all inner loops Yes, and although I think making this a runtime object is an interesting thought (in terms of

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Alexandre Brault
On 2017-03-03 01:52 PM, Chris Angelico wrote: > On Sat, Mar 4, 2017 at 5:50 AM, Matthias Bussonnier > wrote: >> Thanks, I think it does make sens, I'm going to guess, >> outerloop.brk(inners=True) might also be helpful if you have more >> inners loops. I think that implicitely breaking inner ones

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Chris Angelico
On Sat, Mar 4, 2017 at 5:56 AM, Matthias Bussonnier wrote: >> *scratches head* How do you break an outer loop without breaking the >> inner loop? What happens? > > Finish running the inner, then breaking the outer. Instead of breaking > inner and outer. > > for i in outer: > bk = False > f

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matthias Bussonnier
> *scratches head* How do you break an outer loop without breaking the > inner loop? What happens? Finish running the inner, then breaking the outer. Instead of breaking inner and outer. for i in outer: bk = False for j in inner: if cond: bk = True if bk:

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Chris Angelico
On Sat, Mar 4, 2017 at 5:50 AM, Matthias Bussonnier wrote: > Thanks, I think it does make sens, I'm going to guess, > outerloop.brk(inners=True) might also be helpful if you have more > inners loops. I think that implicitely breaking inner ones might > not always be the right thing to do so having

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matthias Bussonnier
Hi Brice, On Fri, Mar 3, 2017 at 10:00 AM, Brice PARENT wrote: > Thanks Matthias for taking the time to give your opinion about it. > > Just to set the focus where I may have failed to point it: > the main purpose of this proposal is the creation of the object itself, an > object representing the

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Brice PARENT
Thanks Matthias for taking the time to give your opinion about it. Just to set the focus where I may have failed to point it: the main purpose of this proposal is the creation of the object itself, an object representing the loop. What we can do with it is still a sub-level of this proposal, as

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Ethan Furman
On 03/03/2017 01:14 AM, Brice PARENT wrote: Sorry for the very long message, I hope it will get your interest. And I also hope my English was clear enough. Long messages that explain the idea are welcome! I think it looks interesting. -- ~Ethan~ __

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Ethan Furman
On 03/03/2017 08:21 AM, Matthias Bussonnier wrote: ## # forloop.break(), to break out of nested loops (or explicitly out of current #loop) - a little like pep-3136's first proposal has_dog_named_rex = False for owner in owners: for dog in dog

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matt Gilson
Thanks for the idea and prior research. I'm not convinced that this warrants new syntax. Most of what you propose (skipping, counting, exposing a length if available, tracking if completed) could be solved already by creating your own wrapper around an iterable: elements_loop = ForLoopIterationO

Re: [Python-ideas] For/in/as syntax

2017-03-03 Thread Matthias Bussonnier
Hi Brice, On Fri, Mar 3, 2017 at 1:14 AM, Brice PARENT wrote: > > A word about compatibility and understandability before: > "as" is already a keyword, so it is already reserved and easy to parse. It > couldn't be taken for its other uses (context managers, import statements > and > exceptions)