"Structural pattern matching" for Python, part 1
"Structural pattern matching" for Python, part 1
Posted Aug 6, 2020 8:46 UTC (Thu) by Karellen (subscriber, #67644)In reply to: "Structural pattern matching" for Python, part 1 by pj
Parent article: "Structural pattern matching" for Python, part 1
I like it, but couldn't you just use as assignment expression and do:
match p := get_point():
The advantage of case (x, y): is that it will match any tuple and allow you to access the members as x and y, whereas doesn't your syntax only allow you to access structures whose members are already called x and y? Feel like I'm missing something here...
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.
