A free, self-paced textbook in 8 chapters. Read a chapter, then drill it with the 263 companion flashcards using spaced repetition.
Python is a high-level, interpreted, dynamically typed language created by Guido van Rossum in 1991. The language is shaped by PEP 8, its official style guide, and PEP 20, Tim Pete...
Python's dynamic type system relies on behavior-based dispatch, a property known as duck typing: rather than checking declared types, code asks whether an object can perform a requ...
Python distinguishes iterables — objects that can return an iterator via `__iter__` — from iterators, which implement both `__iter__` and `__next__`. When an iterator is exhausted,...
Functions are first-class objects that can be wrapped to modify behavior through decorators. The `@decorator` syntax above a definition is syntactic sugar equivalent to `f = decora...
Python integrates objects with language syntax through dunder (double underscore) methods. `__init__` initializes a newly created instance, while `__new__` actually creates and ret...
PEP 484 introduced optional type annotations specifying expected types, supported by the `typing` module which provides generics like `List`, `Dict`, `Optional`, `Union`, and `Call...
CPython's Global Interpreter Lock (GIL) ensures that only one thread executes Python bytecode at a time, simplifying memory management but limiting CPU-bound multithreading paralle...
Python's standard library is extensive. The `collections` module adds specialized containers: `namedtuple` creates tuple subclasses with named fields, `OrderedDict` maintains inser...