A structured, notebook-based Python reference: from syntax basics to object oriented programming, regular expressions, type hints, comprehensions and itertools. Every topic is a notebook with explanations and code examples.
Read it online: Python Complete Reference Notebook on Kaggle
- Offline notebooks in
notebooks/: 87 notebooks in 13 folders, one topic per notebook, meant for studying and quick lookup. - One unified notebook in
kaggle/: all 13 parts in a single file (311 cells, 138 of them code) with a clickable roadmap, a table of contents and an A-Z index of every name it explains. It is designed to run top to bottom without manual input and is the source of the Kaggle notebook above.
A beginner-to-intermediate refresher: short explanations, quick tables and runnable examples, meant for revision and quick lookup rather than deep dives.
Not covered: metaclasses, C extensions, CPython internals, packaging and publishing, threads, processes and asyncio beyond the keywords, web frameworks and data-science libraries. The standard-library modules math, random, datetime, os, sys and functools are not covered yet.
Part N of the unified notebook is the folder N - ... in notebooks/, and section N.M is file M - ... inside that folder. For example, section 5.9 (Decorators) is 05 - Functions/09 - Decorators.
| Part | Topic | Notebooks | What it covers | Suggested background |
|---|---|---|---|---|
| 1 | Python Fundamentals | 8 | Comments, data types & strings, variables, type conversion, user input, string formatting, operators, all 35 keywords | Start here |
| 2 | Python Collections | 7 | Lists, tuples, sets & frozen sets, dictionaries, Counter / defaultdict / deque and the rest of collections, booleans, container comparison guide |
Part 1 |
| 3 | Built-ins & Modules | 5 | Built-in functions by category, built-in modules and import, packages and the __main__ guard, command-line arguments, external packages with pip |
Parts 1-2 |
| 4 | Control Flow | 6 | if / elif / else, match / case, while and for loops, iterables vs iterators, generators |
Parts 1-2 |
| 5 | Functions | 10 | Parameters, defaults, *args / **kwargs, scope, return, recursion, lambda, decorators, docstrings |
Parts 1, 4 |
| 6 | File Handling | 5 | Opening, reading and writing files, file modes, seek / tell, pathlib, JSON, CSV |
Parts 1, 5 |
| 7 | Errors & Exceptions | 5 | Common exception types, raise, try / except / else / finally, context managers, custom exceptions and chaining, logging |
Parts 1, 4, 5 |
| 8 | Regular Expressions | 5 | Regex syntax, character classes, quantifiers, groups, assertions, the re functions, flags and performance |
Part 1 (strings) |
| 9 | Object Oriented Programming | 13 | Classes, encapsulation, inheritance and MRO, polymorphism, ABCs, dunder methods, descriptors, dataclasses, design patterns | Parts 1-5, 7 |
| 10 | Type Hinting | 6 | Type hint basics, unions and aliases, generics, protocols, TypedDict, advanced typing, runtime introspection, 3.14 notes |
Parts 5, 9 |
| 11 | Comprehensions | 5 | List, set, dict and generator expressions, conditions, nested comprehensions, scope, the walrus operator, async comprehensions, performance and readability | Parts 1-2, 4 |
| 12 | Itertools | 8 | Infinite iterators, slicing and filtering, chaining and zipping, accumulate / pairwise / batched / tee, groupby, combinatorics, recipes |
Parts 4, 5, 11 |
| 13 | Testing, Debugging & Profiling | 4 | Reading tracebacks, assert, pdb, unittest, doctest, timeit, cProfile, tracemalloc |
Parts 5, 7 |
Open 00 - Python Notebook Content for a quick offline index (written in Arabic), or use the list below.
01 - Python Fundamentals (8 notebooks)
02 - Python Collections (7 notebooks)
03 - Built-ins & Modules (5 notebooks)
04 - Control Flow (6 notebooks)
05 - Functions (10 notebooks)
06 - File Handling (5 notebooks)
07 - Errors & Exceptions (5 notebooks)
08 - Regular Expressions (5 notebooks)
09 - Object Oriented Programming (13 notebooks)
01 - OOP Foundations02 - Classes, Instances & __init__03 - Attributes & Methods04 - Encapsulation & Properties05 - Class & Static Methods06 - Inheritance & super07 - Multiple Inheritance, MRO & Mixins08 - Polymorphism, Duck Typing & Composition09 - Abstract Base Classes10 - Dunder Methods & Operator Overloading11 - Object Model, Descriptors & __slots__12 - Dataclasses & Enums13 - OOP Design, Advanced Patterns & Best Practices
10 - Type Hinting (6 notebooks)
01 - Type Hints Foundations02 - Collections, Union Types & Type Aliases03 - TypeVar, Generic, Literal, Final & ClassVar04 - Protocols, TypedDict, NamedTuple & Callable05 - Advanced Type Hints_ Self, TypeGuard, overload, ParamSpec & Annotated06 - Typing Tools, Runtime Introspection & Python 3.14 Notes
11 - Comprehensions (5 notebooks)
12 - Itertools (8 notebooks)
13 - Testing, Debugging & Profiling (4 notebooks)
Export the unified notebook to a single HTML file. It opens in any browser without Python or an internet connection, and the roadmap links and Ctrl+F search work:
jupyter nbconvert --to html --execute kaggle/Python-Complete-Reference.ipynb--execute runs every cell first and stops at the first error, so the command also checks that the notebook still runs top to bottom.
Only Python and JupyterLab are needed. The notebooks use the standard library only, so there is nothing else to install.
cd python-complete-reference
pip install jupyterlab
jupyter labNotes:
- Python version: use Python 3.13 or newer for the offline notebooks. Two Type Hinting notebooks demonstrate newer features (
typealiases need 3.12+,typing.TypeIsneeds 3.13+). The unified notebook inkaggle/includes version guards and is written to run on Python 3.11 or newer. It was executed from top to bottom on Python 3.12. - Run cell by cell in the offline notebooks. Some cells show errors or wait for keyboard input on purpose, so "Run All" can stop early there. The unified notebook is the version designed for "Run All".
- Language: everything is in English, except the
00index notebook and two short annotations in01 - Python Fundamentals/02 - Data Typesand02 - Python Collections/03 - Sets & Frozen Sets, which contain a few Arabic words.
python-complete-reference/
├── README.md
├── LICENSE
├── kaggle/
│ ├── Python-Complete-Reference.ipynb # unified notebook (source of the Kaggle notebook)
│ └── kernel-metadata.json # Kaggle API metadata
└── notebooks/
├── 00 - Python Notebook Content.ipynb
├── 01 - Python Fundamentals/
├── 02 - Python Collections/
├── 03 - Built-ins & Modules/
├── 04 - Control Flow/
├── 05 - Functions/
├── 06 - File Handling/
├── 07 - Errors & Exceptions/
├── 08 - Regular Expressions/
├── 09 - Object Oriented Programming/
├── 10 - Type Hinting/
├── 11 - Comprehensions/
├── 12 - Itertools/
└── 13 - Testing, Debugging & Profiling/
After editing kaggle/Python-Complete-Reference.ipynb, push it with the Kaggle CLI:
kaggle kernels push -p kaggleKeep your Kaggle API credentials (kaggle.json) out of the repository. It is already listed in .gitignore.
Maintained by mahmoud15 on Kaggle. Issues and suggestions are welcome.