"Structural pattern matching" for Python, part 1
"Structural pattern matching" for Python, part 1
Posted Aug 5, 2020 18:10 UTC (Wed) by donacthulhuote (guest, #136577)Parent article: "Structural pattern matching" for Python, part 1
Ignoring the fact I wouldn't be able to use this until wherever I'm working gets to python 3.10, I really like the proposal. The only language I know with similar capabilities is Rust, but once you get used to the syntax (which is admittedly a slight hurdle, and which people far smarter than me are working out in this case), it makes for really clean code in a number of cases (to my eyes). It also feels like a better abstraction for a large number of if statements in the cases where what you really want is, well, to match your object to something.
My only consternation is that a large part of the power in rust is that you're forced to deal with all cases, and compiler will help you along if you're missing anything. Python being dynamic doesn't have that luxury, and I wonder how much utility is lost thereby.
