Python Under the Hood

Python that actually matters for ML — interactive, in the browser.

01

Data Types & Variables

Bools, floats, ints, and None vs False.

02

Operators & Expressions

Division, chaining, walrus, is vs ==.

03

Control Flow

Loops, else clauses, and range surprises.

04

Functions & Scope (LEGB)

LEGB, mutable defaults, *args.

05

Lists & Slicing

Copies, slices, and the * trap.

06

Strings

Immutability, interning, f-strings.

07

Tuples

(1,) vs (1) — and mutable insides.

08

Dictionaries

Key hashing gotchas, .get() vs [].

09

Sets

frozenset, unions, and dedup.

10

Classes & OOP

Class attrs, MRO, and super().

11

Iterators & Generators

yield, exhaustion, and genexps.

12

Exceptions

try/except/else/finally order.

13

Python Gotchas — Greatest Hits

The ultimate boss chapter. Mutable defaults, late-binding closures.

14

NumPy & Tensor Fundamentals for Transformers

Reshape, transpose, broadcast, matmul, softmax

15

Coding Transformer Building Blocks

Build every Transformer component from scratch in pure Python/NumPy.

16

PyTorch for Transformers

A full PyTorch chapter.