Ecosystem & ToolingLesson 1 of 2
The Standard Library
Modern Node has a decent built-in library: node:path, node:fs, fetch (Node 18+), crypto.randomUUID(), structuredClone(), and even a test runner. Python's standard library ("batteries included") goes further, and many tasks that still send JS developers to npm need no install at all in Python.
pathlib turns paths into objects. You join them with the / operator (Path.home() / ".config" / "app.json") and read, write, glob, and inspect them through methods: .read_text(), .write_text(), .exists(), .mkdir(parents=True), .parent, .suffix.
itertools and functools cover much of what people install lodash for. itertools gives you lazy combinators: chain (flatten), product (cartesian product), combinations, permutations, groupby, batched. functools adds partial (pre-fill arguments, like fn.bind(null, a)), cache and lru_cache (memoization decorators), and reduce.
datetime and zoneinfo handle dates and time zones without moment, date-fns, or dayjs. argparse builds command-line interfaces (commander/yargs territory), csv reads and writes CSV, sqlite3 gives you an embedded SQL database, json and re cover JSON and regex, and python -m http.server serves the current folder in one line.
The collections module deserves special mention: Counter counts things, defaultdict eliminates key-existence checks, deque is a fast double-ended queue, and namedtuple creates lightweight immutable records. (OrderedDict is mostly historical; regular dicts keep insertion order since 3.7.)
Rule of thumb: before you pip-install anything, search "python stdlib" plus what you need. There is a good chance it is already there.
Quick reference
| JavaScript | Python | Note |
|---|---|---|
| node:path (built in) | pathlib.Path (built in) | Paths are objects |
| lodash | itertools, functools, collections | Built in |
| date-fns / dayjs | datetime, zoneinfo | Built in |
| crypto.randomUUID() | uuid.uuid4() | Both built in |
| commander / yargs | argparse | Built in |
| csv-parse | csv | Built in |
| npx http-server | python -m http.server 8000 | One-line dev server |
Side by side
// Node.js: some built in, some from npm
import path from "node:path";
path.join("src", "data", "file.txt");
crypto.randomUUID();
// Still common npm installs:
import _ from "lodash";
_.flatten([[1, 2], [3, 4]]);
_.countBy(["a", "b", "a"]);
import { format } from "date-fns";
format(new Date(), "yyyy-MM-dd");# Python: all standard library
from pathlib import Path
Path("src") / "data" / "file.txt"
import uuid
str(uuid.uuid4())
from itertools import chain
list(chain([1, 2], [3, 4])) # [1, 2, 3, 4]
from collections import Counter
Counter(["a", "b", "a"]) # Counter({'a': 2, 'b': 1})
from datetime import date
date.today().isoformat() # '2026-10-04'
from functools import cache
@cache
def slow_square(n):
return n * n
# One-line dev server:
# python -m http.server 8000Exercise
Real Python, running in your browserUse Python's standard library to solve these tasks (no installs needed):
words = ["python", "js", "python", "go", "js", "python"] # already defined
1. p = a Path to "data/output/results.csv"; parent = its parent directory
2. word_counts = the frequency of each word in words (collections)
3. today = today's date as a "YYYY-MM-DD" string
4. Memoize this function with functools (lru_cache or cache):
def fibonacci(n):
if n < 2:
return n
return fibonacci(n - 1) + fibonacci(n - 2)Ctrl + Enter runCtrl + Shift + Enter checkTab indentEsc then Tab to leave the editorCtrl + / comment