mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
bpo-42128: Add documentation for pattern matching (PEP 634) (#24664)
This is a first edition, ready to go out with the implementation. We'll iterate during the rest of the period leading up to 3.10.0. Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: Fidget-Spinner <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Brandt Bucher <brandt@python.org> Co-authored-by: Raymond Hettinger <1623689+rhettinger@users.noreply.github.com> Co-authored-by: Guido van Rossum <guido@python.org>
This commit is contained in:
parent
d20279494a
commit
a22bca6b1e
5 changed files with 821 additions and 3 deletions
|
|
@ -259,9 +259,8 @@ Why isn't there a switch or case statement in Python?
|
|||
-----------------------------------------------------
|
||||
|
||||
You can do this easily enough with a sequence of ``if... elif... elif... else``.
|
||||
There have been some proposals for switch statement syntax, but there is no
|
||||
consensus (yet) on whether and how to do range tests. See :pep:`275` for
|
||||
complete details and the current status.
|
||||
For literal values, or constants within a namespace, you can also use a
|
||||
``match ... case`` statement.
|
||||
|
||||
For cases where you need to choose from a very large number of possibilities,
|
||||
you can create a dictionary mapping case values to functions to call. For
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue