Download fixtures/pattern_lab/src/notes.py from tailot/codex-python: direct link, hf CLI and curl.
- Browser
- Download file 484 Bytes
-
https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/notes.py
- Command line
-
hf download hf://datasets/tailot/codex-python/fixtures/pattern_lab/src/notes.py
-
curl -L -o notes.py https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/pattern_lab/src/notes.py
484 Bytes
| """Reading and writing plain text notes on disk. | |
| One function opens a file and closes it by hand, which is the shape the context manager | |
| pattern rewrites. The other already scopes its handle, and the pattern says so. | |
| """ | |
| def read_note(path): | |
| handle = open(path, "r", encoding="utf-8") | |
| body = handle.read() | |
| handle.close() | |
| return body | |
| def write_note(path, body): | |
| with open(path, "w", encoding="utf-8") as handle: | |
| handle.write(body) | |
| return len(body) | |