"Structural pattern matching" for Python, part 2
"Structural pattern matching" for Python, part 2
Posted Sep 2, 2020 19:25 UTC (Wed) by mb (subscriber, #50428)Parent article: "Structural pattern matching" for Python, part 2
we chose a simpler rule: named constants are only recognized when referenced via some namespace, such as `mod.var` or `Color.RED`
Oh, come on...
That is even more awful than using cryptic special characters like dots.
That means whether a variable is read from or written to depends on how I "fetch" a variable name.
The equal character would IMO be the obvious and intuitive character to mark that something is going to be assigned to.
match t:
case (USE_RECT, real=, imag=):
return complex(real, imag)
case (USE_POLAR, r=, phi=):
return complex(r * cos(phi), r * sin(phi))
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.
