files and i/o — moving data in and out7 / 9
pathlib — the file api ai should reach for first
AI wrote a function that reads a config file and falls back to a
default if the file is missing. Trouble is, the function calls
read_text first and then has nothing to catch the
FileNotFoundError. The script crashes when the path doesn't exist.
Add an if path.exists(): guard so the function returns
"default config" when the file is missing and the file's contents
when it exists.
The break is on lines 4, 7 — but read the whole snippet first.
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _