Download Python/train/3.11/pattern-matching/modern_14.py from SwashBuckler001/idiombench: direct link, hf CLI and curl.
- Browser
- Download file 401 Bytes
-
https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.11/pattern-matching/modern_14.py
- Command line
-
hf download hf://datasets/SwashBuckler001/idiombench/Python/train/3.11/pattern-matching/modern_14.py
-
curl -L -o modern_14.py https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.11/pattern-matching/modern_14.py
401 Bytes
| from dataclasses import dataclass | |
| class Point: | |
| x: int | |
| y: int | |
| def where_is(point): | |
| match point: | |
| case Point(x=0, y=0): | |
| print("Origin") | |
| case Point(x=0, y=y): | |
| print(f"Y={y}") | |
| case Point(x=x, y=0): | |
| print(f"X={x}") | |
| case Point(): | |
| print("Somewhere else") | |
| case _: | |
| print("Not a point") | |