▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
The standard library tour
datetime, random, math, os and pathlib: batteries included.
🎬 Video version coming soon — read it now
Python comes with hundreds of modules already installed, called the standard library. People say Python comes with "batteries included". Here are the ones you'll use most.
datetime: dates and times
random: chance and choices
math: beyond + - * /
pathlib: working with files and folders
Path works the same on Windows, Mac and Linux, and the / operator joins folder and file names safely. Prefer it over building paths with strings.
os: talking to the operating system
Environment variables matter later: they're where you'll keep API keys, never in your code.
More worth knowing about
- statistics: mean, median, stdev
- collections: Counter, defaultdict (in the advanced course)
- re: regular expressions for text patterns
- urllib and http: basic web requests (most people use the requests package instead)
- zipfile, shutil: zip, copy and move files
In one line
The standard library gives you dates, randomness, maths, files and system access with nothing to install.
Share with a friend