[Python-Dev] Re: PEP 622 idea: "match case object" to represent match patterns

2020-07-18 Thread Federico Salerno
On 18/07/2020 11:09, Steven D'Aprano wrote: On Sat, Jul 18, 2020 at 10:58:17AM +0200, Federico Salerno wrote: We don't, after all, confuse function calls for references to a function, or vice-versa. Beginners do. Frequently. Sometimes it is quite a hurdle for them to learn to write `function()

[Python-Dev] Re: PEP 622 idea: "match case object" to represent match patterns

2020-07-18 Thread Steven D'Aprano
On Sat, Jul 18, 2020 at 10:58:17AM +0200, Federico Salerno wrote: > We don't, after all, > confuse function calls for references to a function, or vice-versa. Beginners do. Frequently. Sometimes it is quite a hurdle for them to learn to write `function()` instead of `function`. And even experi

[Python-Dev] Re: PEP 622 idea: "match case object" to represent match patterns

2020-07-18 Thread Federico Salerno
On 18/07/2020 02:10, Guido van Rossum wrote: [...] it was quickly pointed out by my co-authors that this doesn't fly, because when the parser sees `case other_3d_point:` it doesn't know whether you meant this as a capture pattern (binding the variable `other_3d_point`) or as a pattern object.

[Python-Dev] Re: PEP 622 idea: "match case object" to represent match patterns

2020-07-17 Thread Guido van Rossum
On Thu, Jul 16, 2020 at 9:21 AM Federico Salerno wrote: > [...] Now consider the following refactor: > > 3d_point = MatchCase("Point(x, y, z)") > other_3d_point = MatchCase("Point(_, _, _)") > point_with_my_y = MatchCase("Point(_, {})", my_y) # syntax with {} is > debatable. > other_2d_point =