Lesson 3.3

Dates, paths, and the standard library

Datetimes come in naive and aware flavours, and mixing them raises an error at the worst moment.

35mBeginner18.3k students

Overview

Most of what you need already ships with Python

Datetimes come in naive and aware flavours, and mixing them raises an error at the worst moment. Store and compute in UTC, convert to a local zone only for display, and the entire category of bug disappears.

Path objects replace string concatenation for filesystem work. Joining, extension changes, and existence checks all become methods, and the result is correct on every platform.

Before adding a dependency, check the standard library. Grouping, permutations, temporary files, and configuration parsing are all already there.

In this lesson you will:

  • Handle time zones without guessing
  • Build file paths that work anywhere
  • Reach for the standard library first

Resources

Previous Lesson
Next Lesson
Dates, paths, and the standard library — Python Foundations for Data Work — Vertex