Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f8ef095
Add section on soft keywords "match" and "case"
dmoisset Feb 23, 2021
2a1b2e1
Add tutorial on pattern matching
dmoisset Feb 23, 2021
83495ea
move index and link down to correct (original) location, add index f…
Fidget-Spinner Feb 24, 2021
4fda91c
Add "_" as a soft keyword
dmoisset Feb 26, 2021
f07fe3e
Add __match_args__ to the data model
dmoisset Feb 26, 2021
72ce7cc
Add versionadded to datamodel
Fidget-Spinner Feb 27, 2021
faa0450
Rename __match_args__ section link
Fidget-Spinner Feb 27, 2021
0392e9c
object.__match_args__ -> class.__match_args__
Fidget-Spinner Feb 27, 2021
e9a33ed
Refer to match wherever the C switch statement was compared with Python.
dmoisset Feb 27, 2021
734dfea
Revert "object.__match_args__ -> class.__match_args__"
dmoisset Feb 27, 2021
cd736dd
Refer to the PEP tutorial from the tutorial
dmoisset Feb 27, 2021
bdcf259
Add half of PEP 634 (lots of TODOs left)
Fidget-Spinner Feb 21, 2021
0e2d768
use better wording and add lots of lists and tables (still lots of TO…
Fidget-Spinner Feb 23, 2021
2790c6e
done!
Fidget-Spinner Feb 24, 2021
82aa7dc
Apply suggested changes from code review by Daniel (part 1)
Fidget-Spinner Feb 27, 2021
ab3ca5a
Apply final suggestions
Fidget-Spinner Feb 27, 2021
26ef46d
Add link, make grammar and links consistent with rest of docs
Fidget-Spinner Feb 27, 2021
f13eb7f
touch up table
Fidget-Spinner Feb 27, 2021
43e9419
Add the datamodel __match_args__ links in
Fidget-Spinner Feb 27, 2021
3bb4f3f
Apply suggestions from code review
dmoisset Feb 27, 2021
0b3d46a
Fix documentation build errors
dmoisset Feb 27, 2021
d0ce4d8
📜🤖 Added by blurb_it.
blurb-it[bot] Feb 27, 2021
3d8cbd6
Clean linter issues
dmoisset Feb 28, 2021
afa3ca0
*TypeError* -> :exc:`TypeError` in Doc/reference/datamodel.rst
Fidget-Spinner Feb 28, 2021
b9d1321
Delete news file: shares same news as Brandt's PR
Fidget-Spinner Feb 28, 2021
1f4d697
update link in compound statements
Fidget-Spinner Feb 28, 2021
a55a396
Better detail on what a soft keyword actually is
dmoisset Feb 28, 2021
68e0251
Rework the sequence of steps in the overview
dmoisset Feb 28, 2021
7a2cb66
Add some comments to the example
dmoisset Feb 28, 2021
66f3435
Made the irrefutable definition slightly more stricter
dmoisset Feb 28, 2021
e783adb
Move table rows as apragraphs into the description of each pattern
dmoisset Feb 28, 2021
f9e1193
Apply my two specific suggestions from code review
gvanrossum Mar 1, 2021
6fafe4b
Final suggestion by Carol
gvanrossum Mar 1, 2021
365912c
delete redundant paragraph since table is gone
Fidget-Spinner Mar 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions 5 Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect it would be better to rewrite or remove this section, but not now. IMO "match" is the missing switch/case statement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or update the question to be: Is there a switch or case statement in Python?


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
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.