Browse by Topic

Popular

Latest

Latest Posts

Illustration of Python OR pattern combining two match cases with a vertical bar symbol
Python

Python OR Pattern: Combining Match Cases

Combine multiple cases in Python's match statement with the OR pattern using the | operator. Learn syntax, capture rules, guards, and common pitfalls.

Pythonpattern matchingmatch statementOR operator
A clean diagram showing Python class pattern elements like dataclass, property, and descriptor.
Python

Python Class Pattern Idioms for Clean Code

Explore practical Python class patterns using dataclasses, properties, descriptors, class methods, and metaclasses to write cleaner, more maintainable object-oriented code.

PythonObject-Oriented ProgrammingDataclassesDescriptors
Illustration of a Python mapping pattern matching dictionary keys and values in a match statement.
Python

Python Mapping Pattern: Match Dictionaries

Learn Python's mapping pattern for `match/case`: matching dictionaries by keys, capturing values, nesting patterns, and using `**rest` to handle extra keys.

structural pattern matchingmatch statementdictionariespattern matching
Illustration of Python sequence pattern matching showing a list being decomposed into its elements with a match arrow.
Python

Python Sequence Pattern Matching

python sequence pattern: Learn how to use Python sequence patterns in match statements, including star patterns, guards, and making custom sequence types matchable.

pattern matchingmatch statementsequencestar pattern
Illustration of a Python file with wildcard asterisk and question mark symbols matching multiple file names.
Python

Python Wildcard Pattern Matching with fnmatch and glob

Learn Python's wildcard pattern matching with fnmatch, glob, and pathlib to filter strings and file paths using *, ?, and character sets.

pythonfnmatchglobpattern-matching
Illustration of Python capture pattern binding a value from a match statement to a variable.
Python

Python Capture Pattern: Syntax and Usage

Learn how Python capture patterns bind values to names in match statements, including sequence and class examples, wildcard behavior, and common pitfalls.

pythonstructural pattern matchingmatch statementcapture pattern
Illustration of Python match statement with literal patterns matching exact values like numbers and strings.
Python

Python Literal Pattern: Match Exact Values

python literal pattern: Learn how to use literal patterns in Python's match statement to match exact values like integers, strings, booleans, and None, with practical...

structural pattern matchingmatch statementliteral patternsPython 3.10
A split diagram contrasting thread-local storage in threads with contextvars context propagation across async tasks in Python.
Python

Python ContextVars vs Threading Local: Which to Use

Compare contextvars and threading.local for per-request state in Python, including async task isolation, context copying, and when to use each.

contextvarsthreading.localasyncioconcurrency
Diagram of isolated context containers propagating values through asynchronous tasks
Python

Python Contextvars Usage: Async State Without Globals

Practical guide to python contextvars usage: set, get, reset, context propagation in asyncio, threading behavior, and request-scoped state patterns.

contextvarsasyncioconcurrencythreading
Illustration of a Python context variable acting as a scoped container for async tasks, with arrows showing context propagation.
Python

Python Context Variable: Scoped State for Async and Threads

python context variable: Learn how Python's contextvars module provides async-safe, scoped state that works across tasks and threads without passing arguments everywhere.

contextvarsasynciothreadingscoped state