On 11/13/2020 1:48 PM, Joao S. O. Bueno wrote:
On Fri, 13 Nov 2020 at 17:36, Jim J. Jewett <jimjjew...@gmail.com
<mailto:jimjjew...@gmail.com>> wrote:
I *hope* this was a typo! If
case Point(x=a, y=b):
assigns to a and b (instead of x and y, as in a normal call), then
that is ... going to be very easy for me to forget, and to miss
even when I'm aware of it.
No typo - this is _precisely_what the main proposal on PEPs 634, 635
and 636 is suggesting, and tha PEP 642 is trying to avoid.
And the claim is, that there are people that think this is a good idea❓❓
And are actually proposing to add it to Python❓
Here it is working as is on my Python with PEP 622 build:
```
Python 3.10.0a0 (heads/patma:1ba56a003b, Aug 6 2020, 02:00:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: fromdataclassesimportdataclass
In [2]: @dataclass
...: classPoint:
...: x: float
...: y: float
...:
In [3]: defget_coords(p):
...: match p:
...: case Point(x=a, y=b):
...: returna, b
...: case _:
...: raiseTypeError()
...:
In [4]: get_coords(Point(3, 4))
Out[4]: (3, 4)
```
-jJ
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/UVOJJF37B5Q5IQJWV3YKBOZA23BY6XI5/
Code of Conduct: http://python.org/psf/codeofconduct/