Skip to content

Advanced Python — Overview

You already know Python’s basics — variables, functions, classes, collections, async. The advanced tier is where Python’s design philosophy really shines. These are the tools that make large Python codebases readable, fast, and maintainable.

If you come from TypeScript, you already have strong intuitions about types, generics, decorators, and structured testing. This module maps those intuitions directly to their Python equivalents — and flags the places where Python does something there is simply no TS parallel for.

LessonCore conceptTS parallel
Typing & ProtocolsProtocol, TypeVar, TypedDict, Optional/UnionStructural interfaces, generics, mapped types
Dataclasses@dataclass, frozen, field()Class + interface hybrid, records
Metaclasses & Descriptors__get__/__set__, type subclassingNo equivalent — Python-only power
itertools & functoolschain, groupby, lru_cache, partialLodash / Array methods
Pattern Matchingmatch/case with structural patternsswitch + destructuring
pytest deep-diveFixtures, parametrize, assertionsJest: beforeEach, it.each, expect
Profilingtimeit, cProfile, reading statsNode --prof, console.time

Python’s type system is opt-in and runtime-invisible — just like TypeScript’s types disappear after compilation. The difference is that Python’s annotations survive as metadata you can inspect, which is exactly what dataclasses, Protocol, and TypedDict rely on.

TypeScript
// TypeScript — types are a compiler concern
interface Shape {
area(): number;
}
// Generics are erased at runtime
function first<T>(arr: T[]): T {
return arr[0];
}
Python
# Python — types are annotations (not enforced)
from typing import Protocol, TypeVar
class Shape(Protocol):
def area(self) -> float: ...
T = TypeVar('T')
def first(arr: list[T]) -> T:
return arr[0]
print(first([10, 20, 30])) # 10

Each lesson follows the same pattern:

  1. TS analogy first — anchor in what you already know.
  2. Python mechanics — the actual syntax and semantics.
  3. Interactive playground (where the concept is self-contained).
  4. PyOnly callouts — things that have no TS equivalent.
  5. Quiz — a quick knowledge check.

Work through them in order, or jump to the lesson most relevant to your current project.

Which Python module provides `Protocol`, `TypeVar`, and `TypedDict`?
Python type hints are enforced at runtime by default.