[Python-ideas] Re: [RFC] "Strict execution mode" (TL;DR version)

2020-12-03 Thread Paul Sokolovsky
Hello, On Wed, 2 Dec 2020 19:24:08 +1100 Chris Angelico wrote: > On Wed, Dec 2, 2020 at 7:11 PM Paul Sokolovsky > wrote: > > > Python can't change its execution plans based on type > > > > CPython can't, other Pythons can. Mypyc is a well-known Python which > > changes its execution plans bas

[Python-ideas] Make for/while loops nameable.

2020-12-03 Thread Jonatan
Hi, sometimes I do nested loops and I want to break specific loop, outer/inner etc. I need to do an ugly thing with for..else and it's annoying. It'd be nice if we could do so: for i in range(10) as loop_i: for j in range(i, i + 10) as loop_j: if i + j == 9: break loop_i o

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Abdur-Rahmaan Janhangeer
Greetings list, I wonder if the issue should be named as: introduce absolute break in Python as if you have 5 nested loops (which you probably should not), breaking loop_i won't do anything Kind Regards, Abdur-Rahmaan Janhangeer about | blog

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Paul Moore
On Thu, 3 Dec 2020 at 11:07, Jonatan wrote: > > Hi, sometimes I do nested loops and I want to break specific loop, > outer/inner etc. > I need to do an ugly thing with for..else and it's annoying. > > It'd be nice if we could do so: > for i in range(10) as loop_i: > for j in range(i, i + 10)

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Mathew Elman
I personally am +1 for something like this. What about for use with `continue` as well? e.g. > for i in range(10) as i_loop: > for j in range(i, i + 10) as j_loop: > if i + j == 9: > continue i_loop which will break out of j_loop and go to the next i (as if the `continue

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread M.-A. Lemburg
On 03.12.2020 12:06, Jonatan wrote: > Hi, sometimes I do nested loops and I want to break specific loop, > outer/inner etc. > I need to do an ugly thing with for..else and it's annoying. > > It'd be nice if we could do so: > for i in range(10) as loop_i: > for j in range(i, i + 10) as loop_j

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Paul Sokolovsky
Hello, On Thu, 03 Dec 2020 11:06:41 - "Jonatan " wrote: > Hi, sometimes I do nested loops and I want to break specific loop, > outer/inner etc. I need to do an ugly thing with for..else and it's > annoying. > > It'd be nice if we could do so: > for i in range(10) as loop_i: > for j in r

[Python-ideas] Re: [RFC] "Strict execution mode" (TL;DR version)

2020-12-03 Thread Paul Sokolovsky
Hello, On Wed, 2 Dec 2020 21:15:22 +1100 Steven D'Aprano wrote: > On Wed, Dec 02, 2020 at 10:52:30AM +0300, Paul Sokolovsky wrote: > > [Paul] > > > > # Leads to a warning: replacing (monkey-patching) a constant > > > > slot (function) with a variable. > > > > mod.func1 = 1 > > [...] > > >

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Jonathan Fine
Hi Jonatan Please consider for a in aaa: for b in bbb: if condition(a, b): break KEYWORD: break where KEYWORD is like else, but with the opposite semantics. I think this does exactly what you asked for, in your example. In July this year

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Chris Angelico
On Fri, Dec 4, 2020 at 12:25 AM Jonathan Fine wrote: > > Hi Jonatan > > Please consider > for a in aaa: > for b in bbb: > if condition(a, b): > break > KEYWORD: > break > where KEYWORD is like else, but with the opposite semantics. I thin

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Jonathan Fine
Hi On Thu, Dec 3, 2020 at 2:02 PM Chris Angelico wrote: > well... uhhh Technically you can do that already > > for a in aaa: > for b in bbb: > if condition(a, b): > break > else: > continue # We didn't break from b, so continue a > break # We did b

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Serhiy Storchaka
03.12.20 15:59, Chris Angelico пише: > well... uhhh Technically you can do that already > > for a in aaa: > for b in bbb: > if condition(a, b): > break > else: > continue # We didn't break from b, so continue a > break # We did break b, so break a >

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Chris Angelico
On Fri, Dec 4, 2020 at 2:42 AM Jonathan Fine wrote: > > Hi > > On Thu, Dec 3, 2020 at 2:02 PM Chris Angelico wrote: >> >> well... uhhh Technically you can do that already >> >> for a in aaa: >> for b in bbb: >> if condition(a, b): >> break >> else: >> c

[Python-ideas] Re: [RFC] "Strict execution mode" (TL;DR version)

2020-12-03 Thread David Mertz
On Thu, Dec 3, 2020 at 8:31 AM Paul Sokolovsky wrote: > I'm not sure if you already smell it in the air, but the idea of a > "fully compliant Python" is getting old (simply because it was there > all this time, and people learned its drawbacks too). [... etc ...] I'm not sure if anyone else fee

[Python-ideas] Re: [RFC] "Strict execution mode" (TL;DR version)

2020-12-03 Thread Paul Sokolovsky
Hello, On Thu, 3 Dec 2020 16:25:09 + David Mertz wrote: > On Thu, Dec 3, 2020 at 8:31 AM Paul Sokolovsky > wrote: > > > I'm not sure if you already smell it in the air, but the idea of a > > "fully compliant Python" is getting old (simply because it was there > > all this time, and people

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Aveheuzed
Hi everyone, I'm not in favor of naming loops, as this looks too much like variable. (What happens when variable names and loop names names collide ? Does the loop identifier bind to anything ?) On the other hand, I like the feature very much, and I have thought about it in the past. My take

[Python-ideas] Question about binary dunder deferring logic

2020-12-03 Thread Sebastian Berg
Hi all, I just sniped myself wondering about how correct dispatching for dunders works for independently derived subclasses. This is an extreme corner case where two subclasses may not know about each other, and further cannot establish a hierarch: class A(int): pass class B(int

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Abdulla Al Kathiri
Why not start at break 0 not break 1, similar to sequences starting at index 0? Maybe if break alone without integer, it breaks from the loop it is at similar to the behavior we have right now in Python. E.g., for matrix in matrix_array : # Index 0 for x in range(0,10) : # Index 1

[Python-ideas] Re: Question about binary dunder deferring logic

2020-12-03 Thread Sebastian Berg
On Thu, 2020-12-03 at 13:10 -0600, Sebastian Berg wrote: > Hi all, > > I just sniped myself wondering about how correct dispatching for > dunders works for independently derived subclasses. Sorry, this was likely mostly noise... I had forgotten about the asymmetry in `__add__` and `__radd__` [1]

[Python-ideas] Re: Make for/while loops nameable.

2020-12-03 Thread Aveheuzed
Why not start at break 0 not break 1, similar to sequences starting at index 0? Maybe if break alone without integer, it breaks from the loop it is at similar to the behavior we have right now in Python. E.g., for matrix in matrix_array : # Index 0     for x in range(0,10) : # Index 1