Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

A clean diagram showing Python's built-in data types grouped into scalar, sequence, mapping, set, and binary categories.
Python

Python Built-in Data Types: A Practical Reference

python built in data types: Practical guide to Python's built-in data types: behavior, performance characteristics, and when to choose each type for real-world code.

pythondata-typesmutable-vs-immutablepython-collections
Illustration of Python data type containers showing mutable and immutable categories with a code snippet background
Python

Understanding Python Data Types

A practical guide to Python's built-in data types, their mutability, performance tradeoffs, and how to use type hints effectively in real code.

Pythondata typestype hintsmutability
Diagram showing a walrus operator binding a value into a named variable inside a conditional expression, with scope arrows indicating where the variable remains visible.
Python

Python Walrus Operator Usage: Syntax, Scope, Pitfalls

python walrus operator usage: Learn how the Python walrus operator (:=) works: syntax, practical patterns in loops and comprehensions, scope rules, and when to avoid it.

walrus operatorassignment expressionspython syntaxlist comprehensions
Illustration of the walrus operator := used in a Python conditional expression.
Python

Python Assignment Expression: Syntax and Practical Use

Understand when the Python assignment expression (the walrus operator) improves code and when a normal assignment is clearer, with syntax and examples.

walrus operatorpython syntaxpython 3.8conditional expressions
Illustration of the Python walrus operator showing assignment expression syntax in a code context.
Python

Python Walrus Operator: Syntax, Use Cases, and Pitfalls

Learn how the Python walrus operator (:=) works, when it improves code, and where it can hurt readability and maintainability.

walrus operatorassignment expressionspython syntaxpython 3.8
Illustration of Python variable annotation syntax showing a variable name, colon, and type.
Python

Python Annotated Variables: Syntax and Practical Use

Learn how to annotate variables in Python, how annotations differ from type hints, and how static type checkers use them.

type hintsvariable annotationsPEP 526static typing
Illustration of Python variable type annotation concept showing a variable with a type label and a magnifying glass representing static type checking.
Python

Python Variable Type Annotation: Syntax and Usage

Learn how to use Python variable type annotations to document expected types, improve code clarity, and enable static type checking with mypy.

type annotationstyping modulemypystatic typing
Illustration of Python code with type annotations and a shield icon representing static type checking.
Python

Python Type Hints: Syntax, Tools, and Runtime

How to use Python type hints: annotation syntax, common patterns, static checking with mypy, and runtime behavior.

type hintstypingmypystatic analysis
Illustration comparing dynamic and static typing in Python with a balance scale and type annotations.
Python

Python Dynamic Typing vs Static Typing: When to Use Each

Learn the practical differences between Python's dynamic typing and static type checking, including runtime behavior, type hints, mypy, and when each approach is the right fit.

dynamic typingstatic typingtype hintsmypy
Illustration of Python strong typing with type hints and static type checking.
Python

Python Strong Typing: Type Hints and Static Checks

Understand what strong typing means in Python, how type hints and static checkers like mypy help catch type errors, and when runtime validation is needed.

type hintsmypystatic typingduck typing