1. Concept library
  2. Python Foundations
  3. Module 8: Modules and packages

Concept

The standard library

Python ships with modules for most everyday jobs: paths, dates, JSON, CSV, random numbers, counting and more. Knowing what is already there saves writing it or installing it.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Name the standard library modules for paths, dates, JSON, CSV and counting
  2. Use pathlib, datetime and json to solve a small task without installing anything
  3. Decide when a third-party package is worth it over the standard library

In practice

A few lines that show The standard library doing its job.

Python
import csv, json
from datetime import date, timedelta
from pathlib import Path

due = date.today() + timedelta(days=3)
print(due.isoformat())

rows = list(csv.DictReader(Path("people.csv").open()))
print(json.dumps(rows[:1], indent=2))

The common mistake

Watch for

Reaching for pip install before checking the standard library. Parsing CSV, dates and JSON by hand, or with a third-party package, when csv, datetime and json already do it well.

What to know first

Your roadmap puts these before The standard library, unless you already know them.

How it stays learned

Once a session shows you understand The standard library, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled
Previous in the module← Virtual environments