Elena' s AI Blog

Python's Standard Library: Your Built-in Toolkit

15 May 2026 (updated: 17 Aug 2026) / 19 minutes to read

Elena Daehnhardt


Generated by Midjourney. Prompt: Cyborg with a human head — the developer-AI hybrid at work.


TL;DR:
  • Python's standard library covers most everyday tasks out of the box. Learn pathlib for file paths, datetime for dates and times, json for data exchange, random for simulations, and dataclasses as a clean step toward OOP — all without installing a single package.

Previous: Part 3 — Python Error Handling: When Birds Misbehave

Next: Part 5 — Python classes and pigeons

Python Standard Library: What Ships Without Installing Anything

In the previous post we learned to handle errors gracefully. Now let us talk about something that will save you enormous amounts of time: Python’s standard library.

The Python Standard Library is the collection of modules that ships with every Python installation, covering file system operations, dates and times, data serialisation, mathematics, networking, testing, and compression without requiring a single third-party install. The first instinct of many beginners — and honestly of many experienced developers — is to reach for a third-party package. Often the right answer is already in the box.

The Python community has a saying: batteries included. This post is about finding the batteries.

Python Modules and the import Statement

Before exploring specific modules, a quick note on how to use them. A module is a Python file — or a package of files — that you bring into your script with import:

import math
print(math.sqrt(144))  # 12.0

If you only need one thing from a module, from x import y keeps the namespace cleaner:

from math import sqrt, pi
print(sqrt(144))  # 12.0
print(pi)         # 3.141592653589793

You can alias a module to a shorter name with as:

import datetime as dt
today = dt.date.today()

That is all there is to it. The rest is knowing which modules exist and what they do.

pathlib — File Paths Done Right

🔒 Subscribe to keep reading.

datetime — Dates and Times

🔒 Subscribe to keep reading.

json — Data Exchange

🔒 Subscribe to keep reading.

random — Controlled Randomness

🔒 Subscribe to keep reading.

dataclasses — Structured Data Without Ceremony

🔒 Subscribe to keep reading.

Complete Example: Combining pathlib, json, random, and dataclasses

🔒 Subscribe to keep reading.

Python Standard Library vs Third-Party Packages: When to Reach for Each

🔒 Subscribe to keep reading.

References

🔒 Subscribe to keep reading.

Subscribe to unlock the full article ❤️

I keep most of the site completely open. A few unusually detailed tutorials need a free subscriber login so I can keep publishing this kind of work.

The form below signs you up for the newsletter. It does not log you into the app — log in afterwards (same email) to unlock this article and download your subscriber gifts. New subscribers get an inbox mail: Set a password to unlock articles.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2026) 'Python's Standard Library: Your Built-in Toolkit', daehnhardt.com, 15 May 2026. Available at: https://daehnhardt.com/blog/2026/05/15/python-standard-library/
All Posts