[Python-Dev] Re: PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-18 Thread Guido van Rossum
(For people who fail to find any mention of protocols in PEP 634, Protocols (PEP 544) can be used (with the @runtime decorator) to override isinstance(), and class patterns are defined to use isinstance() for the class check.) On Wed, Nov 18, 2020 at 11:50 AM Brett Cannon wrote: > > > On Wed, No

[Python-Dev] Re: Questions about about the DLS 2020

2020-11-18 Thread Guido van Rossum
On Wed, Nov 18, 2020 at 11:39 AM Brett Cannon wrote: > My question about adding pattern matching later was more to comment on the > fact that the languages that use "_" for a wildcard pattern did it from > early on, not later on; it had nothing to do with the proposal proposing > pattern matching

[Python-Dev] Re: PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-18 Thread Brett Cannon
On Wed, Nov 18, 2020 at 1:25 AM Robin Becker wrote: > Is there a bestiary of examples for the current pattern matching > proposal(s)? > > It seems I don't have a good handle on how one matches simple tests like > callability, Doable using protocols. > function signatures, I don't think that

[Python-Dev] Re: Why does "except Ex as x" not restore the previous value of x?

2020-11-18 Thread Brett Cannon
On Tue, Nov 17, 2020 at 10:16 PM Greg Ewing wrote: > On 18/11/20 4:36 pm, Larry Hastings wrote: > > > > But, > > the thinking went, you'd never want to examine the last value from a > > list generator, so it was more convenient if it behaved as if it had its > > own scope. > > List comprehensions

[Python-Dev] Re: Questions about about the DLS 2020

2020-11-18 Thread Brett Cannon
On Tue, Nov 17, 2020 at 1:16 PM Tobias Kohn wrote: > Hi Brett, > > Without having really looked at the history of all the languages we > mention in the PEPs, I have a hunch that most of them had pattern matching > from quite the beginning or an early stage on, indeed. That being said, I > think

[Python-Dev] Re: The semantics of pattern matching for Python

2020-11-18 Thread Daniel Moisset
[sorry for the duplicate, meant to reply-all] Thank you for this approach, I find it really helpful to put the conversation in these terms (semantics and guiding principles). This is not an answer to the proposal (which I've read and helps me contextualize) but to your points below and how they a

[Python-Dev] PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-18 Thread Robin Becker
Is there a bestiary of examples for the current pattern matching proposal(s)? It seems I don't have a good handle on how one matches simple tests like callability, function signatures, possession of specific attribute(s).etc. Also will matching ever extend into the Typing universe? -- Rob