Download fixtures/pattern_lab/src/retries.py from tailot/codex-python: direct link, hf CLI and curl.
- Browser
- Download file 462 Bytes
-
https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/retries.py
- Command line
-
hf download hf://datasets/tailot/codex-python/fixtures/pattern_lab/src/retries.py
-
curl -L -o retries.py https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/retries.py
462 Bytes
| """Failure handling around an object that reads. | |
| One handler catches every exception the interpreter can raise, and that is the shape | |
| the narrow exception pattern rewrites. The other handler already names its exception, | |
| and the pattern says so. | |
| """ | |
| def call_or_none(source): | |
| try: | |
| return source.read() | |
| except: | |
| return "" | |
| def call_or_note(source): | |
| try: | |
| return source.read() | |
| except ValueError: | |
| return "no source" | |