]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46059: Clarify pattern-matching example in "control flow" docs (GH-30079)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Tue, 14 Dec 2021 15:04:29 +0000 (15:04 +0000)
committerGitHub <noreply@github.com>
Tue, 14 Dec 2021 15:04:29 +0000 (23:04 +0800)
The "Color" example in the pattern-matching section of the "control flow" documentation is not immediately runnable, leading to confusion.

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Doc/tutorial/controlflow.rst

index a8197566026122296272fa90e7ee528cae21ec08..fad8746014646c1d463ed68cd19662662534136e 100644 (file)
@@ -395,9 +395,11 @@ Several other key features of this statement:
 
       from enum import Enum
       class Color(Enum):
-          RED = 0
-          GREEN = 1
-          BLUE = 2
+          RED = 'red'
+          GREEN = 'green'
+          BLUE = 'blue'
+
+      color = Color(input("Enter your choice of 'red', 'blue' or 'green': "))
 
       match color:
           case Color.RED: