Download Python/train/3.14/variable-annotations/modern_11.py from SwashBuckler001/idiombench: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.14/variable-annotations/modern_11.py
- Command line
-
hf download hf://datasets/SwashBuckler001/idiombench/Python/train/3.14/variable-annotations/modern_11.py
-
curl -L -o modern_11.py https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.14/variable-annotations/modern_11.py
481 Bytes
| class Starship: | |
| captain: str = 'Picard' | |
| damage: int | |
| stats: ClassVar[Dict[str, int]] = {} | |
| def __init__(self, damage: int, captain: str = None): | |
| self.damage = damage | |
| if captain: | |
| self.captain = captain # Else keep the default | |
| def hit(self): | |
| Starship.stats['hits'] = Starship.stats.get('hits', 0) + 1 | |
| enterprise_d = Starship(3000) | |
| enterprise_d.stats = {} # Flagged as error by a type checker | |
| Starship.stats = {} # This is OK | |