A script that runs on a server shouldn't have its folders, batch sizes or tokens typed into the code. They come from environment variables (os.environ) and settings files, so the same code runs on your laptop and in production with different values.
Three things trip people up:
- Everything in the environment is text.
"250" needs int(), and bool("false") is True, because any non-empty text is truthy.
- Settings are often missing. Read them with
.get(name, default) instead of [name].
- Order matters. A common rule: built-in defaults, then the settings file, then environment variables, with the last one winning.
Python reads TOML files with tomllib, which needs the file opened in binary mode. In these exercises, env is a dictionary that stands in for os.environ, so nothing changes your real environment.
Out: (250, True). The batch size converts cleanly, but bool("false") is True: flags need a real comparison.