[Python-Dev] PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Nick Coghlan
I’ve made a final round of updates to PEP 642 and submitted it to the Steering Council for consideration alongside PEP 634. As usual, the rendered version can be found here: https://www.python.org/dev/peps/pep-0642/ There's a Discourse thread at https://discuss.python.org/t/pep-642-v3-explicit-pa

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Barry Scott
> On 3 Jan 2021, at 15:21, Nick Coghlan wrote: > > I’ve made a final round of updates to PEP 642 and submitted it to the > Steering Council for consideration alongside PEP 634. > > As usual, the rendered version can be found here: > https://www.python.org/dev/peps/pep-0642/ > > There's a Disc

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Antoine Pitrou
On Sun, 3 Jan 2021 16:19:01 + Barry Scott wrote: > > > > I’ll also quote the example match statement from the PEP abstract, > > which extracts “host” and “port” details from a 2 item sequence, a > > mapping with “host” and “port” keys, any object with “host” and “port” > > attributes, or a “h

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Paul Moore
On Sun, 3 Jan 2021 at 16:26, Barry Scott wrote: > I read the above and believe I know what it meant without needing to read the > PEP in detail. > I like that a lot. Personally, I read it and was horribly confused. I worked out most of it, but I would *not* count it as intuitive or natural. Spe

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Ethan Furman
On 1/3/21 8:50 AM, Paul Moore wrote: Personally, I read it and was horribly confused. case object{.host as host, .port as port}: pass Leading periods is a big no-go for me, for all the reasons listed in the original thread. I have not read the full PEP, so take this

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Paul Sokolovsky
Hello, On Sun, 3 Jan 2021 16:50:33 + Paul Moore wrote: > On Sun, 3 Jan 2021 at 16:26, Barry Scott > wrote: > > I read the above and believe I know what it meant without needing > > to read the PEP in detail. I like that a lot. > > Personally, I read it and was horribly confused. I worked

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Nick Coghlan
On Mon, 4 Jan 2021, 2:19 am Barry Scott, wrote: > > I quickly read 642 v3 and missed an explanation about why the syntax to > match a string object is > str{} and not str. Are you saying that I MUST use {} so that when case is > parsed its clear that its a class > with no constraints? > Yes. "s

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Nick Coghlan
On Mon, 4 Jan 2021, 2:50 am Paul Moore, wrote: > On Sun, 3 Jan 2021 at 16:26, Barry Scott wrote: > > I read the above and believe I know what it meant without needing to > read the PEP in detail. > > I like that a lot. > > Personally, I read it and was horribly confused. I worked out most of > i

[Python-Dev] Re: PEP 642 v3: Explicit patterns for structured pattern matching

2021-01-03 Thread Nick Coghlan
On Mon, 4 Jan 2021, 4:34 am Ethan Furman, wrote: > On 1/3/21 8:50 AM, Paul Moore wrote: > > > Personally, I read it and was horribly confused. > > >> case object{.host as host, .port as port}: > >> pass > > Leading periods is a big no-go for me, for all the reasons listed in

[Python-Dev] Descriptors in dataclasses fields

2021-01-03 Thread Josue Balandrano Coronel
I've been exploring dataclasses for a few months now and they've proven to be very useful. The only downside is that there's not a simple way to use descriptors. Descriptors only work on class attributes (as per the docs: https://docs.python.org/3/howto/descriptor.html#closing-thoughts). This m