diff --git a/pep-0622.rst b/pep-0622.rst index ed4c746cb..47c4e9ee3 100644 --- a/pep-0622.rst +++ b/pep-0622.rst @@ -306,7 +306,7 @@ together in this section for simplicity: never binds. - A **capture pattern** looks like ``x`` and is equivalent to an identical assignment target: it always matches and binds the variable - with the given name. + with the given (simple) name. - The **wildcard pattern** is a single underscore: ``_``. It always matches, but does not capture any variable (which prevents interference with other uses for ``_`` and allows for some optimizations). @@ -512,6 +512,7 @@ A capture pattern serves as an assignment target for the matched expression:: case name: print(f"Hi {name}!") +Only a single name is allowed (a dotted name is a constant value pattern). A capture pattern always succeeds. A capture pattern appearing in a scope makes the name local to that scope. For example, using ``name`` after the above snippet may raise ``UnboundLocalError`` rather than ``NameError``, if @@ -2137,6 +2138,8 @@ Version History - Clarify exception and side effect semantics - Clarify partial binding semantics - Drop restriction on use of ``_`` in load contexts + - Drop the default single positional argument being the whole + subject except for a handful of built-in types - Simplify behavior of ``__match_args__`` - Drop the ``__match__`` protocol (moved to `deferred ideas`_) - Drop ``ImpossibleMatchError`` exception