[New-bugs-announce] [issue46059] Typo in match Statement example

Vivek Vashist report at bugs.python.org
Sun Dec 12 19:46:36 EST 2021


New submission from Vivek Vashist <vivekvashist at gmail.com>:

Possible Typo in match statement example. https://docs.python.org/3/tutorial/controlflow.html#match-statements


BROKEN:
> python
Python 3.10.0b4 (default, Nov 15 2021, 18:26:05) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from enum import Enum
>>> class Color(Enum):
...     RED = 0
...     GREEN = 1
...     BLUE = 2
...
>>> match color:
...     case Color.RED:
...         print("I see red!")
...     case Color.GREEN:
...         print("Grass is green")
...     case Color.BLUE:
...         print("I'm feeling the blues :(")
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'color' is not defined. Did you mean: 'Color'?


WORKING:

> python
Python 3.10.0b4 (default, Nov 15 2021, 18:26:05) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>> from enum import Enum
>>> class Color(Enum):
...     RED = 0
...     GREEN = 1
...     BLUE = 2
...
>>> match Color:
...     case Color.RED:
...         print("I see red!")
...     case Color.GREEN:
...         print("Grass is green")
...     case Color.BLUE:
...         print("I'm feeling the blues :(")

----------
assignee: docs at python
components: Documentation
messages: 408415
nosy: docs at python, vivekvashist
priority: normal
severity: normal
status: open
title: Typo in match Statement example
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46059>
_______________________________________


More information about the New-bugs-announce mailing list