Skip to content
Open
Changes from 4 commits
Commits
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
3 changes: 3 additions & 0 deletions Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,11 @@ Why isn't there a switch or case statement in Python?

In general, structured switch statements execute one block of code
when an expression has a particular value or set of values.

Since Python 3.10 one can easily match literal values, or constants
within a namespace, with a ``match ... case`` statement.
See :pep:`634` (specification) and :pep:`636` (tutorial) for details about the ``match`` statement.
Copy link
Member

Choose a reason for hiding this comment

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

For the "(tutorial)" it is probably best to replace the link with a link to the actual tutorial page that covers this.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. The PEPs are historical documents that typically become stale over time. I think that there shouldn't be a link to a PEP for either the specification or tutorial.

Copy link
Author

Choose a reason for hiding this comment

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

So we should add an 'outdated' note in PEP 636, like the one in PEP 634.


An older alternative is a sequence of ``if... elif... elif... else``.

For cases where you need to choose from a very large number of possibilities,
Expand Down
Loading