Browse by Topic

Popular

Latest

Latest Posts

Illustration of Python generic type parameter syntax showing a boxed T type parameter between square brackets in a code editor.
Python

Python Type Parameter Syntax

Learn about Python's modern type parameter syntax introduced in PEP 695, how it compares with the traditional TypeVar approach, and when to use each.

PEP 695GenericsType HintsTypeVar
Diagram showing a generic type parameter T in a Python class box, with arrows indicating type substitution.
Python

Python Generic Syntax: TypeVar, Generic, and PEP 695

Learn Python generic syntax: how TypeVar, Generic, and PEP 695 are used to write reusable, type-checked classes and functions.

Python genericsTypeVartyping modulestatic type checking
Illustration of Python TypeIs narrowing a value to a specific type in a type checker.
Python

Python TypeIs for Precise Type Narrowing

TypeIs gives Python predicate functions a way to narrow types in both branches of a condition. See practical examples and how it differs from TypeGuard.

TypeIsType NarrowingtypingPython 3.13
A shield icon protecting a Python function signature with type annotations, symbolizing runtime type checking.
Python

Python Typeguard: Runtime Type Checking

python typeguard: Learn how to use Python Typeguard to enforce type hints at runtime, catch type errors early, and integrate it with pytest for robust testing.

typeguardruntime type checkingtype hintsPython typing
Editorial illustration of a Python Never type annotation representing a function that never returns, with an unreachable code branch.
Python

Python Never Type: Functions That Never Return

Learn how to use Python's Never type to annotate functions that raise, exit, or loop forever, and how it improves static type checking.

python typingtype hintsnever typemypy
Illustration of Python Self type annotation in a class method returning self, with a visual metaphor of a curved arrow looping back to the class box.
Python

Python Self Type for Method Return Annotations

Learn how to use Python's Self type to annotate methods that return the instance, with correct type inference in subclasses and fluent interfaces.

PythonType HintsSelf TypeMethod Annotations
A diagram showing one Python function with multiple type signature arrows converging into a single implementation block.
Python

Python Overload Type Hints: Multiple Signatures

Use Python's typing.overload to declare multiple type signatures for one function and improve static type checking accuracy.

typingtype hintsoverloadmypy
Illustration of the Python abs() function showing absolute value of a number on a number line.
Python

Python abs() Function: Syntax, Edge Cases, and Usage

Understand Python's abs() function: syntax, behavior with numeric types, custom objects, edge cases, and performance considerations.

pythonabsbuilt-in functionsnumeric types
Illustration of a Python list being converted into a single iterator block by the iter() built-in, with a one-way arrow showing single-pass iteration.
Python

Python iter(): How the Built-in Function Works

Explains Python's iter() built-in: how it creates iterators, the two-argument sentinel form, custom iterator classes, and common edge cases.

pythoniteratorsiterablesgenerators
Illustration of a Python dataclass with a __post_init__ method that validates and computes derived fields after initialization.
Python

Python __post_init__: Customizing Dataclass Initialization

How __post_init__ works in Python dataclasses: validation, derived fields, InitVar, inheritance, frozen instances, and common pitfalls.

dataclassesinitializationvalidationderived fields