python-cheatsheet
Comprehensive Python Cheatsheet
Python Cheatsheet: one file, most of the language
A single comprehensive Python reference, organized into numbered sections that cover collections, data types, syntax, system calls, and data formats.
One document, organized by number
The repo is one thing: a comprehensive Python cheatsheet. The README offers the text file for download, a link to the FAQ, and a table of contents that mirrors the numbered sections. It is meant as a reference for working developers rather than a tutorial. The primary language listed is Python, and the homepage hosts the cheatsheet directly.
Collections and data types
Section 1 covers collections: list, dictionary, set, tuple, range, enumerate, iterator, and generator. Section 2 handles data types: type, string, regular expressions, format, numbers, combinatorics, and datetime. The text deliberately uses the term collection instead of iterable, with the rationale pointed to elsewhere in the notes. Abstract base classes show up too, each one specifying a set of virtual subclasses that isinstance and issubclass recognize as belonging, even when they technically are not.
Syntax, system calls, and formats
Syntax rules cover functions, inline, import, decorators, classes, duck typing, enums, and exceptions. System calls run through exit, print, input, command line arguments, open, path, and OS commands. Data formats include JSON, pickle, CSV, SQLite, bytes, and struct. The arrangement means a working Python session, from command line to file formats, fits under one set of headings.
Notes that teach
Several examples double as explanations. Frozenset is the immutable, hashable version of the normal set, usable as a dict key or a set item. Any function containing a yield statement returns a generator. All values in Python are objects, and every object has a type, with type and class treated as synonyms. The operator module's itemgetter can replace listed lambdas, and sortable details are given for sort, sorted, max, and min. The cheatsheet even suggests normalizing strings with unicodedata before comparing, because a character like ö can be stored in one form or two.
Editorial conclusion
For a single-file reference the coverage is unusually wide. The examples double as small lessons, which makes it useful for review as much as lookup.
Community notes