[Python-ideas] Match statement brainstorm

Michael Selik michael.selik at gmail.com
Wed May 25 02:35:08 EDT 2016


On Wed, May 25, 2016 at 2:26 AM Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:

>
> My feeling is that the patterns should look like
> constructors. The archetypal constructor for a mapping
> object is the dict display, so a pattern that matches
> a mapping having particular keys would be
>
>     case {"x": p, "y": q}:
>

This is starting to look really good to me. But if that's valid in a case
statement, why not in a regular assignment?

    (a, b, *rest) = sequence
    {'x': p, 'y': q, **rest} = mapping
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160525/88f2404d/attachment-0001.html>


More information about the Python-ideas mailing list