python Python PEPs ·

PEP 845 Proposes Leading-Dot Value Patterns for Python's Match Statement

previewengineer
security

PEP 845 proposes enhancing Python's `match` statement with leading-dot value patterns, enabling direct matching against local and global non-attribute names. This simplifies current workarounds using verbose `if` guard clauses, significantly improving pattern matching readability and resolving issues with OR patterns. Python developers will find it easier to compare match subjects against local variables or module-level constants like sentinels. The proposal is a backwards-compatible draft targeting Python 3.16, preferred by a majority of respondents in discussions.

Security (1)
  • Security Implications
Read the original announcement →

https://peps.python.org/pep-0845/

Related releases