Download Python/train/3.13/variadic-generics/modern_04.py from SwashBuckler001/idiombench: direct link, hf CLI and curl.
- Browser
- Download file 368 Bytes
-
https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.13/variadic-generics/modern_04.py
- Command line
-
hf download hf://datasets/SwashBuckler001/idiombench/Python/train/3.13/variadic-generics/modern_04.py
-
curl -L -o modern_04.py https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.13/variadic-generics/modern_04.py
368 Bytes
| class Array(Generic[*Shape]): | |
| def __init__(self, shape: Tuple[*Shape]): | |
| self._shape: Tuple[*Shape] = shape | |
| def get_shape(self) -> Tuple[*Shape]: | |
| return self._shape | |
| shape = (Height(480), Width(640)) | |
| x: Array[Height, Width] = Array(shape) | |
| y = abs(x) # Inferred type is Array[Height, Width] | |
| z = x + x # ... is Array[Height, Width] | |