5
Errors, Files & Modules
Code meets the messy world today: exceptions you can recover from, files you can read and write, and the batteries Python ships with.
Lessons
- 1 Errors & Exceptions Read a traceback, catch what you can handle, raise what you cannot, and stop writing except: pass. exceptions try debugging
- 2 Reading & Writing Files Open files safely with with, read them line by line, write results back, and handle CSV without heroics. files io csv
- 3 Modules & the Standard Library Import code that already exists — math, random, datetime, collections, pathlib — and write your own module. modules imports standard-library
- 4 Python on Your Own Machine Leaving the browser: installing Python, running .py files, virtual environments, and pip. setup pip venv