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
Popular Python guides
Most readLatest Python guides
Page 56 of 179Python Async Task Cancellation: How to Cancel Tasks
python async task cancellation: Learn how to cancel asyncio tasks in Python, handle CancelledError, and use timeouts, shielding, and TaskGroup for robust concurrency.
Python Eager vs Lazy Evaluation: What Actually Runs
Python evaluates expressions eagerly by default; lazy evaluation through generators, iterators, and built-ins changes memory and runtime behavior. This article explains the differences and when to use each.
Python Iterator Lazy Evaluation: How It Works
Understand how Python iterators use lazy evaluation to compute values on demand, reduce memory usage, and process large or infinite sequences.
Python Generator Lazy Evaluation Explained
Understand how Python generators compute values on demand, when lazy evaluation saves memory, and how to combine generators into efficient data pipelines.
Python Dictionary Comprehension Multiple Conditions
python dictionary comprehension multiple conditions: Learn how to use multiple conditions in Python dictionary comprehensions, including if/else, logical operators, an...
Python List Comprehension Multiple Conditions
Use multiple conditions in Python list comprehensions: filter with chained if clauses, transform with if-else expressions, and avoid common syntax errors.
Python Match Class Pattern vs isinstance
Compare Python match class patterns with isinstance() for type checks and attribute extraction, including syntax, guards, runtime behavior, and when to use each.
Python Structural Typing vs Nominal Typing
Understand the difference between Python's nominal and structural typing, how Protocol declares structural contracts, and when @runtime_checkable makes isinstance checks work.
Python __slots__: Advantages and Disadvantages
Understand how Python `__slots__` reduces memory and can speed up attribute access, plus the constraints and inheritance rules it introduces.
Python Callable Object vs Function: Key Differences
python callable object vs function: Understand the difference between Python callable objects and functions, when each fits, and how state and closures change the choice.