Download Python/train/3.9/protocol/modern_29.py from SwashBuckler001/idiombench: direct link, hf CLI and curl.
- Browser
- Download file 232 Bytes
-
https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.9/protocol/modern_29.py
- Command line
-
hf download hf://datasets/SwashBuckler001/idiombench/Python/train/3.9/protocol/modern_29.py
-
curl -L -o modern_29.py https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.9/protocol/modern_29.py
232 Bytes
| class P(Protocol): | |
| x: float | |
| def f(arg: P) -> None: | |
| arg.x = 0.42 | |
| class C: | |
| x: int | |
| c = C() | |
| f(c) # Would typecheck if covariant subtyping | |
| # of mutable attributes were allowed. | |
| c.x >> 1 # But this fails at runtime | |