English
Summary
Conclusions
Modules and packages define responsibility boundaries. A file format is an external contract: you must check not only syntax but also domain meaning. Separate calculations and explicit paths let you test a program quickly and safely in temporary directories.
Self-check questions
- What code runs during the first import?
- How does
sys.modulesdiffer fromsys.path? - Why is the condition involving
__name__needed? - How does a relative import depend on the launch method?
- How does the working directory differ from the module directory?
- Which open modes can change a file?
- Why should encoding be specified explicitly?
- What does JSON lose when converting a tuple or dataclass?
- Why validate structure after
json.loads? - Why can CSV not be split reliably with
split? - What does
pytest.raisescheck? - How does
parametrizeaffect the number of tests? - What isolation guarantees does
tmp_pathprovide? - When are
capsysandmonkeypatchuseful? - Why does 100 percent coverage not prove correctness?