Skip to content

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Complete Reference

A structured, notebook-based Python reference: from syntax basics to object oriented programming, iteration tools, the standard library, regular expressions and type hints. Every topic is a notebook with a quick summary table, explanations and code examples.

Read it online: Python Complete Reference Notebook on Kaggle

What is inside

  • Offline notebooks in notebooks/: 97 notebooks in 14 folders, one topic per notebook, meant for studying and quick lookup.
  • One unified notebook in kaggle/: all 14 parts in a single file (341 cells, 152 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.

Scope

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, networking (urllib, socket), subprocess, web frameworks and data-science libraries.

Learning order

The parts follow a learning path: each part builds on the ones before it. A few one-line examples in Parts 1 and 5 use a construct that is explained later (for example try in Data Types). The Suggested background column lists the earlier parts whose ideas a part uses. Quick References (keywords and built-in functions) is meant for lookup at any time.

Find things fast

You want to... Use
Look up a name (function, method, keyword) The A-Z index at the end of the unified notebook
Find the tool for a job ("how do I remove duplicates?") 14 - Quick References/04 - Task Index
See every method of str, list, tuple, dict or set 14 - Quick References/03 - Methods of Built-in Types
Recall a syntax or the options of a topic The quick table at the top of every notebook
See all keywords or built-in functions The first two notebooks of Quick References

Roadmap

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 4.9 (Decorators) is 04 - Functions/09 - Decorators.

Part Topic Notebooks What it covers Suggested background
1 Python Basics 8 Comments, variables, data types, operators, type conversion, user input, string formatting, modules and import Start here
2 Control Flow 4 if / elif / else, while and for loops, match / case Part 1
3 Data Structures 6 Lists, tuples, sets & frozen sets, dictionaries, references and copying, booleans, container comparison guide Parts 1-2
4 Functions 13 Return values, parameters, defaults, *args / **kwargs, scope, recursion, lambda, decorators, docstrings, type hints, PEP 8 Parts 1-2
5 Errors, Debugging & Profiling 4 Exception types, raise, try / except / else / finally, tracebacks, assert, pdb, timeit, cProfile Parts 1-2, 4
6 Comprehensions, Iterators & Generators 7 List, set, dict and generator expressions, nested comprehensions, iterables vs iterators, generators, scope and the walrus operator Parts 1-2, 4-5
7 Standard Library Essentials 6 math, statistics, decimal, random, datetime, collections, functools Parts 1-2, 4-6
8 Itertools 8 Infinite iterators, slicing and filtering, chaining and zipping, accumulate / pairwise / batched / tee, groupby, combinatorics, recipes Parts 1-2, 4-7
9 Files & Data Formats 6 Reading and writing files, file modes, pathlib, os / sys / shutil, JSON, CSV Parts 1-2, 4-7
10 Regular Expressions 5 Regex syntax, character classes, quantifiers, groups, assertions, the re functions, flags and performance Parts 1-2, 4
11 Object Oriented Programming 16 Classes, encapsulation, inheritance and MRO, custom exceptions, polymorphism, ABCs, dunder methods, context managers, descriptors, dataclasses, class patterns, design patterns Parts 1-2, 4-7, 9
12 Advanced Type Hinting 4 TypeVar and generics, protocols, TypedDict, Self, TypeGuard, overload, ParamSpec, runtime introspection, 3.14 notes Parts 1-2, 4-5, 7, 11
13 Building Real Programs 6 Packages and the __main__ guard, command-line arguments, external packages with pip, logging, unittest, doctest Parts 1-2, 4-6, 9, 11
14 Quick References 4 All 35 keywords with examples, the built-in functions by category, every method of str, list, tuple, dict and set, and a task index (how do I...?) Parts 1-2, 4-9, 11

Notebook index

Open 00 - Python Notebook Content for a quick offline index, or use the list below.

01 - Python Basics (8 notebooks)
02 - Control Flow (4 notebooks)
03 - Data Structures (6 notebooks)
04 - Functions (13 notebooks)
05 - Errors, Debugging & Profiling (4 notebooks)
06 - Comprehensions, Iterators & Generators (7 notebooks)
07 - Standard Library Essentials (6 notebooks)
08 - Itertools (8 notebooks)
09 - Files & Data Formats (6 notebooks)
10 - Regular Expressions (5 notebooks)
11 - Object Oriented Programming (16 notebooks)
12 - Advanced Type Hinting (4 notebooks)
13 - Building Real Programs (6 notebooks)
14 - Quick References (4 notebooks)

Read it offline

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.

Run it locally

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 lab

Notes:

  • Python version: use Python 3.13 or newer for the offline notebooks. Two notebooks demonstrate newer features (type aliases need 3.12+, typing.TypeIs needs 3.13+). The unified notebook in kaggle/ 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 in this repository is in English.

Repository layout

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 Basics/
    ├── 02 - Control Flow/
    ├── 03 - Data Structures/
    ├── 04 - Functions/
    ├── 05 - Errors, Debugging & Profiling/
    ├── 06 - Comprehensions, Iterators & Generators/
    ├── 07 - Standard Library Essentials/
    ├── 08 - Itertools/
    ├── 09 - Files & Data Formats/
    ├── 10 - Regular Expressions/
    ├── 11 - Object Oriented Programming/
    ├── 12 - Advanced Type Hinting/
    ├── 13 - Building Real Programs/
    └── 14 - Quick References/

Update the Kaggle notebook

After editing kaggle/Python-Complete-Reference.ipynb, push it with the Kaggle CLI:

kaggle kernels push -p kaggle

Keep your Kaggle API credentials (kaggle.json) out of the repository. It is already listed in .gitignore.

License

MIT

Maintained by mahmoud15 on Kaggle. Issues and suggestions are welcome.

About

Structured Python reference as Jupyter notebooks: fundamentals, OOP, regex and type hints. Also on Kaggle.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages