Title: suggestion to small improvement of PEP 634 -- Structural Pattern Matching · Issue #1898 · python/peps · GitHub
Open Graph Title: suggestion to small improvement of PEP 634 -- Structural Pattern Matching · Issue #1898 · python/peps
X Title: suggestion to small improvement of PEP 634 -- Structural Pattern Matching · Issue #1898 · python/peps
Description: Firstly, congratulation on PEP 634, I just want to suggest an enhancement for the "match" statement. When the matching against cases of pattern, there are some situations when there is no match. Using a cluster of "else" make it more rea...
Open Graph Description: Firstly, congratulation on PEP 634, I just want to suggest an enhancement for the "match" statement. When the matching against cases of pattern, there are some situations when there is no match. Us...
X Description: Firstly, congratulation on PEP 634, I just want to suggest an enhancement for the "match" statement. When the matching against cases of pattern, there are some situations when there is no...
Opengraph URL: https://github.com/python/peps/issues/1898
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"suggestion to small improvement of PEP 634 -- Structural Pattern Matching","articleBody":"Firstly, congratulation on PEP 634, I just want to suggest an enhancement for the \"match\" statement. \r\n\r\n- When the matching against cases of pattern, there are some situations when there is no match.\r\n- Using a cluster of \"else\" make it more readable compared with using a wildcard case. \r\n- It's likewise in cases of the \"if\", \"for\", \"try\" statements, when conditions are not matching or when elements in a collection are not found, having the cluster of \"else\" in the above-mentioned statements make the code syntaxial readable to express what the Python program should.\r\n\r\nFor example , taken from PEP 636 , instead of :\r\n\r\n```python\r\nmatch command.split():\r\n case [\"go\", direction] if direction in current_room.exits:\r\n current_room = current_room.neighbor(direction)\r\n case [\"go\", _]:\r\n print(\"Sorry, you can't go that way\")\r\n```\r\nthe programmer have express a possible situation as :\r\n\r\n```python\r\nmatch command.split():\r\n case [\"go\", direction] if direction in current_room.exits:\r\n current_room = current_room.neighbor(direction)\r\n case [\"go\", _]:\r\n print(\"Sorry, you can't go that way\")\r\n else : \r\n print( f\"Sorry, I don't understand what you mean by {command}.\")\r\n```\r\n\r\nI hope you got my point.\r\n\r\n\r\n","author":{"url":"https://github.com/alhabshi3k","@type":"Person","name":"alhabshi3k"},"datePublished":"2021-03-29T07:24:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1898/peps/issues/1898"}
| 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:a9960ca1-6b04-b546-c93a-a387d29eb126 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBA8:6EBB8:2739C5:35C15F:6A616183 |
| html-safe-nonce | ed74391c3fdbd66e93eb4fcdfc163d9eab71a0ca8da8b347190d30a412920caa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkE4OjZFQkI4OjI3MzlDNTozNUMxNUY6NkE2MTYxODMiLCJ2aXNpdG9yX2lkIjoiNDkxNDA3MzU0OTE2OTMyMDMyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b20fab7395cb636f68bf577d924e2deaba16165d7e64bc5955a9d1cdfb862956 |
| hovercard-subject-tag | issue:843061819 |
| 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/peps/1898/issue_layout |
| twitter:image | https://opengraph.githubassets.com/46836327faf5831d8911619ccdb0064cab0019c13bd1a10bf00acc9bc88117db/python/peps/issues/1898 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/46836327faf5831d8911619ccdb0064cab0019c13bd1a10bf00acc9bc88117db/python/peps/issues/1898 |
| og:image:alt | Firstly, congratulation on PEP 634, I just want to suggest an enhancement for the "match" statement. When the matching against cases of pattern, there are some situations when there is no match. Us... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alhabshi3k |
| hostname | github.com |
| expected-hostname | github.com |
| None | c258d2b06b498220e3b94af28b26bbbf58f4203a6373725f779afcc867afd263 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/peps git https://github.com/python/peps.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 13414105 |
| octolytics-dimension-repository_nwo | python/peps |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13414105 |
| octolytics-dimension-repository_network_root_nwo | python/peps |
| 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 | 5f67bc431418961e0814f1eb30a4231250e4726d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width