Skip to content

mistake in "Guarding Match-Case Statements" section of "Switch-Case Statement" #497

@FeralWhippet

Description

@FeralWhippet

There is a mistake in description of guarding patterns for match/case statement, in this section:

>>> response_code = 300
>>> match response_code:
...     case int():
...             if response_code > 99 and response_code < 500:
...                 print('Code is a valid number')
...     case _:
...             print('Code is an invalid number')
...
# Code is a valid number

it looks like both a typo (extra ':'), and is formatted like an if statement in the body of the case. it should be:

...     case int() if response_code > 99 and response_code < 500:
...             print('Code is a valid number')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions