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:
Daniel F Moisset 2021-03-01 04:08:38 +00:00 committed by GitHub
parent d20279494a
commit a22bca6b1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 821 additions and 3 deletions

View file

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