Download fixtures/pattern_lab/src/baskets.py from tailot/codex-python: direct link, hf CLI and curl.
- Browser
- Download file 385 Bytes
-
https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/baskets.py
- Command line
-
hf download hf://datasets/tailot/codex-python/fixtures/pattern_lab/src/baskets.py
-
curl -L -o baskets.py https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/baskets.py
385 Bytes
| """Reporting what a basket holds. | |
| One function counts the basket to ask whether it is empty, and that is the shape the | |
| truthiness pattern rewrites. The other already asks directly, and the pattern says so. | |
| """ | |
| def describe(items): | |
| if len(items) == 0: | |
| return "empty" | |
| return "full" | |
| def first_or_none(items): | |
| if not items: | |
| return None | |
| return items[0] | |