|
|
Log in / Subscribe / Register

An overview of structural pattern matching for Python

An overview of structural pattern matching for Python

Posted May 4, 2022 0:41 UTC (Wed) by tialaramex (subscriber, #21167)
Parent article: An overview of structural pattern matching for Python

Structural pattern matching is really nice.

I wondered why they went with a statement, because expression match feels nicer to me. But PEP 635 says they explicitly considered this question and decided against an expression, and they know much more about Python and about Python programmers than I ever will.

However it is painful to see, also in PEP 635, how problematic new keywords are for Python. If the language wants to go around adding keywords (and it seems it does based on this) it needs to find a way to make that less painful, it got lucky for match but it can't count on always getting lucky.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds