Elena' s AI Blog

Python's Standard Library: Your Built-in Toolkit

15 May 2026 (updated: 07 Sep 2026) / 19 minutes to read

Elena Daehnhardt

Generated by Midjourney. Prompt: A very smart parrot writing Python code — humorous developer mascot.


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.

You've hit a Deep Dive tutorial.

I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

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