@@ -258,9 +258,11 @@ is evaluated in all cases.
258258Why isn't there a switch or case statement in Python?
259259-----------------------------------------------------
260260
261- You can do this easily enough with a sequence of ``if... elif... elif... else ``.
262- For literal values, or constants within a namespace, you can also use a
263- ``match ... case `` statement.
261+ In general, structured switch statements execute one block of code
262+ when an expression has a particular value or set of values.
263+ Since Python 3.10 one can easily match literal values, or constants
264+ within a namespace, with a ``match ... case `` statement.
265+ An older alternative is a sequence of ``if... elif... elif... else ``.
264266
265267For cases where you need to choose from a very large number of possibilities,
266268you can create a dictionary mapping case values to functions to call. For
@@ -289,6 +291,9 @@ It's suggested that you use a prefix for the method names, such as ``visit_`` in
289291this example. Without such a prefix, if values are coming from an untrusted
290292source, an attacker would be able to call any method on your object.
291293
294+ Imitating switch with fallthrough, as with C's switch-case-default,
295+ is possible, much harder, and less needed.
296+
292297
293298Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation?
294299--------------------------------------------------------------------------------------------------------
0 commit comments