{"id":20324641,"url":"https://github.com/gh640/python-match-case-examples-ja","last_synced_at":"2025-03-04T10:23:19.927Z","repository":{"id":74923702,"uuid":"381052222","full_name":"gh640/python-match-case-examples-ja","owner":"gh640","description":"(Japanese) Python 3 の構造的パターンマッチング（ match case ）サンプル集","archived":false,"fork":false,"pushed_at":"2021-10-09T11:44:49.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-14T14:17:23.638Z","etag":null,"topics":["python3","python310","structural-pattern-matching"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gh640.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-28T14:03:35.000Z","updated_at":"2021-10-09T11:53:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a95a753-3667-4e1b-9414-f95bcda0330b","html_url":"https://github.com/gh640/python-match-case-examples-ja","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fpython-match-case-examples-ja","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fpython-match-case-examples-ja/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fpython-match-case-examples-ja/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh640%2Fpython-match-case-examples-ja/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gh640","download_url":"https://codeload.github.com/gh640/python-match-case-examples-ja/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241827887,"owners_count":20026791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python3","python310","structural-pattern-matching"],"created_at":"2024-11-14T19:36:45.135Z","updated_at":"2025-03-04T10:23:19.907Z","avatar_url":"https://github.com/gh640.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python 3 構造的パターンマッチングサンプル集\n\n(Japanese) Python 3.10 で導入された Structural Pattern Matching （ `match` `case` 構文）のサンプル集です。\n\n## 必須\n\n- Docker\n- Docker Compose\n\n## 使い方\n\nリポジトリをチェックアウトします。\n\nビルドします。\n\n```bash\ncd python-match-case-examples-ja/\ndocker-compose build\n```\n\nPytest でサンプルを実行します。\n\n```bash\ndocker-compose run --rm python\n```\n\n## サンプル\n\n```python\ndef test_literal_pattern():\n    \"\"\"リテラルパターン\"\"\"\n    number = 10\n    match number:\n        case 0:\n            assert False\n        # 値が一致するものがマッチ\n        case 10:\n            assert True\n        case _:\n            assert False\n```\n\n## テストケース\n\n`test_match_case.py` ファイルに以下のケースが含まれています。\n\n| ケース | 関数 |\n| --- | --- |\n| リテラルパターン | `test_literal_pattern()` |\n| or `\\|` パターン | `test_literal_with_or_pattern()` |\n| キャプチャパターン | `test_capture_pattern()` |\n| ワイルドカード `_` パターン | `test_wildcard_pattern()` |\n| バリューパターン 1 | `test_value_pattern_1_attrs()` |\n| バリューパターン 2 | `test_value_pattern_2_enum()` |\n| グループパターン | `test_group_pattern()` |\n| シーケンスパターン 1 | `test_sequence_pattern_1_list_like_syntax()` |\n| シーケンスパターン 2 | `test_sequence_pattern_2_tuple_like_syntax()` |\n| マッピングパターン | `test_mapping_pattern()` |\n| `if` ガード | `test_if_guard()` |\n| クラスパターン 1 | `test_class_pattern_1_positional_args()` |\n| クラスパターン 2 | `test_class_pattern_2_match_args()` |\n| クラスパターン 3 | `test_class_pattern_3_with_if_guard()` |\n| `as` パターン | `test_as_pattern()` |\n\n## 記事\n\n- [パターンマッチング構文（ match case ）の使い方 - Life with Python](https://www.lifewithpython.com/2021/06/python-structual-pattern-matching.html)\n\n## 参考\n\n- PEP 634 (dev): https://www.python.org/dev/peps/pep-0634/\n- PEP 635 (dev): https://www.python.org/dev/peps/pep-0635/\n- PEP 636 (dev): https://www.python.org/dev/peps/pep-0636/\n- What’s New In Python 3.10  - Python 3.10 documentation: https://docs.python.org/3.10/whatsnew/3.10.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgh640%2Fpython-match-case-examples-ja","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgh640%2Fpython-match-case-examples-ja","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgh640%2Fpython-match-case-examples-ja/lists"}