[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Henk-Jaap Wagenaar
On Wed, 8 Jul 2020 at 21:44, Guido van Rossum wrote: > It works for me. Did you click on the box where the logs are supposed to > appear? It will only show the logs when you click there. > > I did click on that before, but I suddenly had a thought (I should have had long ago): it seems my combina

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Guido van Rossum
It works for me. Did you click on the box where the logs are supposed to appear? It will only show the logs when you click there. On Wed, Jul 8, 2020 at 1:36 PM Henk-Jaap Wagenaar < wagenaarhenkj...@gmail.com> wrote: > On Wed, 1 Jul 2020 at 17:09, Guido van Rossum wrote: > >> If you are interest

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Henk-Jaap Wagenaar
On Wed, 1 Jul 2020 at 17:09, Guido van Rossum wrote: > If you are interested in learning more about how PEP 622 would work in > practice, but don't feel like compiling a Python 3.10 fork from source, > here's good news for you. > > In a hurry? > https://mybinder.org/v2/gh/gvanrossum/patma/master?

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Emily Bowman
On Wed, Jul 8, 2020 at 7:03 AM Kerwin Sun wrote: > I tried with this code: > [...] > def whereis(point): > case w: > print("Not the answer, local w") > case z: > print("The answer") > case _: > print("other") > whereis(42) w, z an

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Stefan Krah
On Wed, Jul 08, 2020 at 07:53:00AM -, Kerwin Sun wrote: > I tried with this code: > ``` > from dataclasses import dataclass > > @dataclass > class Point: > x: int > y: int > > z = 41 > > def whereis(point): > w = 23 > match point: > case Point(0, 0): > pri

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Kerwin Sun
I tried with this code: ``` from dataclasses import dataclass @dataclass class Point: x: int y: int z = 41 def whereis(point): w = 23 match point: case Point(0, 0): print("Origin") case Point(0, y): print(f"Y={y}") case Point(x, 0):

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-08 Thread Kerwin Sun
I tried with this code: ``` from dataclasses import dataclass @dataclass class Point: x: int y: int z = 41 def whereis(point): w = 23 match point: case Point(0, 0): print("Origin") case Point(0, y): print(f"Y={y}") case Point(x, 0):

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-03 Thread Federico Salerno
+1 Is there a reason, after all, why we should mark constant patterns as special, and not the opposite? On 02/07/2020 19:10, Walter Dörwald wrote: On 1 Jul 2020, at 18:54, Brandt Bucher wrote: Walter Dörwald wrote: This looks strange to me. In all other cases of variable lookup the global

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-02 Thread Walter Dörwald
On 1 Jul 2020, at 18:54, Brandt Bucher wrote: Walter Dörwald wrote: This looks strange to me. In all other cases of variable lookup the global variable z would be found. The next case assigns to z, making z local to whereis. This is consistent with python's existing scoping rules (for exampl

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Greg Ewing
On 2/07/20 9:25 am, Matthias Bussonnier wrote: It's still weird user experience as if you swap case .z and case z you don't get the Unbound error anymore. It also won't work as intended, because 'case z' will always match and it will never get to 'case .z'. -- Greg ___

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Greg Ewing
On 2/07/20 4:54 am, Brandt Bucher wrote: It sounds like you want to add "global z" to the top of the function definition. Or more likely, change the last case to 'case _'. -- Greg ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe se

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Robert Collins
On Thu, 2 Jul 2020 at 09:28, Matthias Bussonnier wrote: > > It's still weird user experience as if you swap case .z and case z you don't > get the Unbound error anymore. SO it can work w/o global. For some value of work: if z comes before .z, the .z branch will never get evaluated, because the b

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Matthias Bussonnier
It's still weird user experience as if you swap case .z and case z you don't get the Unbound error anymore. SO it can work w/o global. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https:

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Brandt Bucher
Walter Dörwald wrote: > This looks strange to me. In all other cases of variable lookup the global > variable z would be found. The next case assigns to z, making z local to whereis. This is consistent with python's existing scoping rules (for example, try rewriting this as the equivalent if-el

[Python-Dev] Re: PEP 622 (match statement) playground

2020-07-01 Thread Walter Dörwald
On 1 Jul 2020, at 17:58, Guido van Rossum wrote: If you are interested in learning more about how PEP 622 would work in practice, but don't feel like compiling a Python 3.10 fork from source, here's good news for you. In a hurry? https://mybinder.org/v2/gh/gvanrossum/patma/master?urlpath=lab/