Skip to content
IT Vizag
← Files, Modules & Packages

▶ 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

Lesson 5 of 10 · 2 min read

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

🔒 Code example: sign up free (above) to unlock it.

random: chance and choices

🔒 Code example: sign up free (above) to unlock it.

math: beyond + - * /

🔒 Code example: sign up free (above) to unlock it.

pathlib: working with files and folders

🔒 Code example: sign up free (above) to unlock it.

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

🔒 Code example: sign up free (above) to unlock it.

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
Tip: Before installing a package or writing something yourself, search "python standard library <task>". The answer is often already built in.

In one line

The standard library gives you dates, randomness, maths, files and system access with nothing to install.

Saved on this device. Sign in to keep progress everywhere.

Share with a friend