News for hackers. Stuff that matters.
Re:Pattern matching accepted for Python by kortex on Tuesday February 09, 2021 @11:16PM (#26085691)
I dig it. 'as' primes my brain to something going into a scoped context.
Re:Pattern matching accepted for Python by Spivak on Wednesday February 10, 2021 @12:34AM (#26086009)
It’s fine. Python just introduced expression assignment. Why not use that?

    match subject
        case [first := _, rest := _]
            return [rest, first]
Re:Pattern matching accepted for Python by kortex on Wednesday February 10, 2021 @10:44AM (#26090662)
That works too but I guess I am still getting used to the walrus operator. What really bugs me about this PEP is they are going through all this effort to introduce match but they don't have match assignments, which is personally one of my favorite things about match.
Re:Pattern matching accepted for Python by collyw on Wednesday February 10, 2021 @03:50AM (#26086892)
Well get to Perl eventually
Re:Pattern matching accepted for Python by pfalcon on Wednesday February 10, 2021 @05:04AM (#26087369)
Note that the original PEP622 relied on ":=" initially, but they found some corner case with it (apparently, operator precedence related) and switched to "as" in PEP634.