GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — The example using match keyword isn't complete · Issue #95986 · python/cpython

The example using match keyword isn't complete #95986

New issue
Copy link
New issue
Copy link
Closed
Closed
The example using match keyword isn't complete#95986
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@Aljumaily
Aljumaily
opened on Aug 14, 2022
Issue body actions

Documentation

The Other Key Features in What’s New In Python 3.10 contains the following code snippet:

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 :(")

However, the variable color is unknown, hence, NameError: name 'color' is not defined is shown. The solution is the declare a color variable and assign it any of the Color enum values, like so:

from enum import Enum
class Color(Enum):
    RED = 0
    GREEN = 1
    BLUE = 2

color = Color.BLUE

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 :(")

Activity

  1. Aljumaily
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Aug 14, 2022
  2. 180909
    added a commit that references this issue on Aug 15, 2022

    pythongh-95986: Fix the example using match keyword

    2aaae60
  3. nanjekyejoannah
    added a commit that references this issue on Oct 6, 2022

    gh-95986: Fix the example using match keyword (#95989)

    cd0fde2
  4. carljm
    added 2 commits that reference this issue on Oct 6, 2022

    Merge branch 'main' into dictwatch

    7938d6f

    Merge branch 'main' into typewatch

    1af2a98
  5. mpage
    added a commit that references this issue on Oct 11, 2022

    pythongh-95986: Fix the example using match keyword (python#95989)

    a0d2d63
  6. hauntsaninja commented on Oct 11, 2022

    @hauntsaninja
    hauntsaninja
    on Oct 11, 2022
    Contributor
    More actions

    Looks like a PR was merged for this

  7. hauntsaninja
    closed this as completedon Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.