[Python-checkins] bpo-46059: Clarify pattern-matching example in "control flow" docs (GH-30079)
Fidget-Spinner
webhook-mailer at python.org
Tue Dec 14 10:04:39 EST 2021
https://github.com/python/cpython/commit/1cbb88736c32ac30fd530371adf53fe7554be0a5
commit: 1cbb88736c32ac30fd530371adf53fe7554be0a5
branch: main
author: Alex Waygood <Alex.Waygood at Gmail.com>
committer: Fidget-Spinner <28750310+Fidget-Spinner at users.noreply.github.com>
date: 2021-12-14T23:04:29+08:00
summary:
bpo-46059: Clarify pattern-matching example in "control flow" docs (GH-30079)
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 at users.noreply.github.com>
files:
M Doc/tutorial/controlflow.rst
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index a819756602612..fad8746014646 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -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:
More information about the Python-checkins
mailing list