Browse by Topic

Popular

Latest

Latest Posts

Illustration comparing mutable and immutable objects in Python, showing a list that can be modified and a tuple that cannot.
Python

Python Mutable vs Immutable: How It Impacts Your Code

Understand how Python's mutable and immutable types behave differently in assignment, function calls, and memory usage, and how to choose the right type for your data.

PythonMutableImmutableData Types
A visual comparison of Python abstract class inheritance and protocol structural typing.
Python

Python Abstract Class vs Protocol: When to Use Each

python abstract class vs protocol: Compare Python abstract classes and typing.Protocol to decide when each fits your design, with syntax examples and tradeoffs.

abstract classprotocolstructural subtypingtype hints
A diagram showing two Python class design patterns: inheritance as a tree and composition as a network of connected parts.
Python

Python Inheritance vs Composition: Choosing the Right Design

Compare Python inheritance and composition with code examples, tradeoffs, and guidance for choosing the right design.

object-oriented programminginheritancecompositioncode reuse
Illustration of shallow and deep copy in Python showing shared nested lists versus duplicated nested lists.
Python

Python Shallow Copy vs Deep Copy: Key Differences

python shallow copy vs deep copy: Understand the difference between shallow and deep copy in Python, when nested objects are shared, and how to choose the right copyin...

Pythoncopy moduledeepcopymutable objects
Diagram showing the order of __new__ and __init__ calls during Python object creation
Python

Python __new__ vs __init__: When to Use Each

python **new** vs **init**: Understand the difference between Python's __new__ and __init__ methods, when to override each, and how they control object creation.

python__new____init__object creation
Diagram contrasting an instance method receiving self versus a classmethod receiving cls in Python
Python

Python Instance Method vs Classmethod: What Gets Passed

Understand the difference between Python instance methods and classmethods: what gets passed as the first argument, how inheritance behaves, and when to use each.

pythonclassmethodinstance-methodpython-oop
Diagram showing a nested Python function with global and nonlocal scope bindings
Python

Python global vs nonlocal: Scope Rules Explained

python global vs nonlocal: Understand the difference between global and nonlocal in Python, how each affects variable assignment, and when to use them in nested functi...

Python scopingnonlocal keywordglobal keywordclosures
Illustration comparing Python *args and **kwargs function parameters
Python

Python args vs kwargs: Choosing the Right Function Parameters

Learn how Python's *args and **kwargs work, when to use each, and how they affect function design and maintainability.

pythonargskwargsfunction parameters
Diagram contrasting a Python iterator object with a generator function using yield, showing lazy evaluation with a stream of data.
Python

Python Iterator vs Generator: Key Differences

Understand the practical differences between Python iterators and generators, including lazy evaluation, memory usage, and when to use each.

iteratorsgeneratorsyieldlazy evaluation
Illustration comparing a Python iterable container with an iterator pointer moving through elements
Python

Python Iterator vs Iterable: Key Differences Explained

python iterator vs iterable: Understand the distinction between iterables and iterators in Python, how the iterator protocol works, and when to use each for efficient...

PythonIteratorsIterablesGenerators