Download Python/train/3.8/protocol/modern_31.py from SwashBuckler001/idiombench: direct link, hf CLI and curl.
- Browser
- Download file 380 Bytes
-
https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.8/protocol/modern_31.py
- Command line
-
hf download hf://datasets/SwashBuckler001/idiombench/Python/train/3.8/protocol/modern_31.py
-
curl -L -o modern_31.py https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.8/protocol/modern_31.py
380 Bytes
| class OldIterable(Sized, Protocol[T]): | |
| def __getitem__(self, item: int) -> T: ... | |
| CompatIterable = Union[Iterable[T], OldIterable[T]] | |
| class A: | |
| def __iter__(self) -> Iterator[str]: ... | |
| class B: | |
| def __len__(self) -> int: ... | |
| def __getitem__(self, item: int) -> str: ... | |
| def iterate(it: CompatIterable[str]) -> None: | |
| ... | |
| iterate(A()) # OK | |
| iterate(B()) # OK | |