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

Illustration of immutable data types in Python showing a locked box with data inside, representing unchangeable objects.
Python

Understanding Python Immutable Data Types

python immutable data types: Learn how Python's immutable data types behave, why they matter for memory and concurrency, and how to build custom immutable objects.

immutabilitypython-typesmemory-managementconcurrency
Diagram showing two variables referencing the same mutable list object, with a mutation symbol indicating in-place change.
Python

Python Mutable Data Types: Behavior and Pitfalls

Learn how Python's mutable data types behave, why assignments and function calls can cause surprising side effects, and how to copy lists, dictionaries, and sets correctly.

PythonMutableImmutableAliasing
Diagram contrasting a mutable list object whose contents change in place with an immutable string object that creates a new value on modification.
Python

Python Mutable vs Immutable Types: Behavior and Tradeoffs

Explains how Python's mutable and immutable types differ in assignment, aliasing, hashing, and memory behavior, with practical code examples and guidance for choosing the right type.

PythonMutable ObjectsImmutable ObjectsData Types
Illustration comparing Python type() and isinstance() functions with inheritance hierarchy.
Python

Python type vs isinstance: When to Use Each

Understand the practical difference between Python's type() and isinstance(), including inheritance behavior, protocol checks, and when to use each.

Pythontype checkingisinstanceduck typing
Illustration of a Python code snippet showing isinstance type checking with a class hierarchy and a checkmark indicating a valid type match.
Python

Using isinstance in Python for Runtime Type Checks

python isinstance: Learn how isinstance works in Python, when to use it over type(), how inheritance affects results, and where runtime type checks are appropriate.

Pythonisinstancetype checkinginheritance
Illustration of Python's type() function showing an object being inspected and a class being created dynamically.
Python

Python type() Function: Runtime Type Inspection and Dynamic Classes

Learn how Python's type() function inspects object types and creates classes dynamically, and when to prefer isinstance() for robust type checking.

type()runtime type checkingisinstancedynamic classes
Diagram showing Python None as a singleton object with identity checks and type hints.
Python

Python None Type: Behavior, Pitfalls, and Best Practices

Understand Python's None type: singleton behavior, is None comparisons, Optional type hints, and common pitfalls like mutable default arguments.

NonePythonType HintsOptional
Illustration of a Python dictionary mapping keys to values with type annotations.
Python

Python Dict Type: Syntax, Typing, and Performance

Learn how the Python dict type works at runtime, how to annotate dicts with type hints, and when to choose another data structure.

Pythondicttype hintsdata structures
An illustration of a frozenset as a locked container holding three distinct colored shapes, positioned beside a dictionary key icon to convey immutability and hashability.
Python

Python frozenset Type: Syntax, Hashability, and Use

Learn the Python frozenset type: creation syntax, hashability for dictionary keys, read-only set operations, memory behavior, and when to choose it over set or tuple.

frozensetpython-setshashable-typesdictionary-keys
Illustration showing duplicate shapes merging into unique elements, representing the Python set type's deduplication behavior.
Python

Python Set Type: Syntax, Operations, and Performance

Learn how the Python set type works: creation syntax, set operators and methods, hash-based membership testing, performance tradeoffs, and common errors.

python setsset operationsdata structuresmembership testing