"Structural pattern matching" for Python, part 1
"Structural pattern matching" for Python, part 1
Posted Aug 7, 2020 21:25 UTC (Fri) by NYKevin (subscriber, #129325)In reply to: "Structural pattern matching" for Python, part 1 by Karellen
Parent article: "Structural pattern matching" for Python, part 1
I interpreted it differently. My understanding of pj's comment was that "p" is not the point you matched against (because then you would just write p = get_point() and skip the entire match statement altogether). Rather, "p" is a generic object whose attributes are populated by the matcher. You could just as easily write "p.foo" and "p.bar" and it would work exactly the same.
Another way to think about it: "p." is a prefix meaning "capture a variable here." If a variable is not prefixed, then it's used as a comparison instead.
