PEP 622: Two small clarifications based on early python-dev feedback

- Emphasize that the capture pattern only allows a simple/single name.
- Add dropping of default "self" positional argument to version history
This commit is contained in:
Guido van Rossum 2020-07-08 13:02:37 -07:00
parent 4d21729080
commit da849ee33c
1 changed files with 4 additions and 1 deletions

View File

@ -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