[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Serhiy Storchaka
22.06.20 18:17, nate lust пише: Matching begins by calling a __match__ (class)method on the type, with the match target as a parameter. The match method must return an object that can be evaluated as a bool. If the return value is True, the code block in this match branch is executed, and

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Joao S. O. Bueno
One should never underestimate the power of Guido's time machine. > ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Guido van Rossum
On Mon, Jun 22, 2020 at 8:20 AM nate lust wrote: > I have been working on an idea that would introduce pattern matching > syntax to python. I now have this syntax implemented in cpython, and feel > this is the right time to gather further input. The repository and branch > can be found at

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Joao S. O. Bueno
On Mon, 22 Jun 2020 at 13:08, Michael Christensen wrote: > Concerning parameters in the as section: I think using `with` would make > it easier to understand. > > try match result: > as Dog: > print("Dog") > as Cat with lives: > print(f"Cat with {lives} lives") > as

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Michael Christensen
Concerning parameters in the as section: I think using `with` would make it easier to understand. try match result: as Dog: print("Dog") as Cat with lives: print(f"Cat with {lives} lives") as tuple with (arg1, arg2): print(f"Tuple with args {arg1}, {arg2}")