Title: The example using match keyword isn't complete · Issue #95986 · python/cpython · GitHub
Open Graph Title: The example using match keyword isn't complete · Issue #95986 · python/cpython
X Title: The example using match keyword isn't complete · Issue #95986 · python/cpython
Description: 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:...
Open Graph Description: 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.RE...
X Description: 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.RE...
Opengraph URL: https://github.com/python/cpython/issues/95986
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The example using match keyword isn't complete","articleBody":"# Documentation\r\n\r\nThe [Other Key Features](https://docs.python.org/3/whatsnew/3.10.html#other-key-features) in [What’s New In Python 3.10](https://docs.python.org/3/whatsnew/3.10.html#what-s-new-in-python-3-10) contains the following code snippet:\r\n```\r\nfrom enum import Enum\r\nclass Color(Enum):\r\n RED = 0\r\n GREEN = 1\r\n BLUE = 2\r\n\r\nmatch color:\r\n case Color.RED:\r\n print(\"I see red!\")\r\n case Color.GREEN:\r\n print(\"Grass is green\")\r\n case Color.BLUE:\r\n print(\"I'm feeling the blues :(\")\r\n```\r\n\r\nHowever, 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:\r\n\r\n```\r\nfrom enum import Enum\r\nclass Color(Enum):\r\n RED = 0\r\n GREEN = 1\r\n BLUE = 2\r\n\r\ncolor = Color.BLUE\r\n\r\nmatch color:\r\n case Color.RED:\r\n print(\"I see red!\")\r\n case Color.GREEN:\r\n print(\"Grass is green\")\r\n case Color.BLUE:\r\n print(\"I'm feeling the blues :(\")\r\n```","author":{"url":"https://github.com/Aljumaily","@type":"Person","name":"Aljumaily"},"datePublished":"2022-08-14T22:17:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/95986/cpython/issues/95986"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bd18fa31-3b04-08a3-339a-3435140448dd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8C0:11D50D:27F3D7:358B08:69697958 |
| html-safe-nonce | 7a4fe9f4ea82d040c574f67ada1df0313a3647b28b112dd3408f5257db0d6655 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEMwOjExRDUwRDoyN0YzRDc6MzU4QjA4OjY5Njk3OTU4IiwidmlzaXRvcl9pZCI6Ijk3MDMyOTMxNjkwNzM4MzEyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 108e4402bff73a3074893057e5c5980b857728e5aad84f3325a34a6d4efa599c |
| hovercard-subject-tag | issue:1338363053 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/95986/issue_layout |
| twitter:image | https://opengraph.githubassets.com/111da96e13f6ea3f3dc80850f34528e89b6e576283efb5dc2fa5060b042af445/python/cpython/issues/95986 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/111da96e13f6ea3f3dc80850f34528e89b6e576283efb5dc2fa5060b042af445/python/cpython/issues/95986 |
| og:image:alt | 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.RE... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Aljumaily |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6f193beb8ff08443adc07685d75302ab8aaf0a135f6e251c3ff3112c8deb881 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 212e3e3d3298bf5b313830edfd2399e869f7ea76 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width