An overview of structural pattern matching for Python
An overview of structural pattern matching for Python
Posted May 4, 2022 7:12 UTC (Wed) by NYKevin (subscriber, #129325)In reply to: An overview of structural pattern matching for Python by epa
Parent article: An overview of structural pattern matching for Python
> The context-aware parser in Python is great as a way to do a smooth upgrade, but I would still appreciate a warning if I have used keywords like match and case as variable names. I would still want to change them everywhere to avoid confusing humans, even if the parser can cope.
You can probably hack that together with ast.walk() and look for ast.Name instances with a "bad" name. I'm pretty sure that's, like, four lines of code. See https://docs.python.org/3/library/ast.html for documentation.