Browse by Topic
Popular
Popular Posts
Latest
Latest Python Posts
Python get Method: Safe Dictionary Access
Learn how Python's dict.get() method provides safe dictionary access with default values, avoids KeyError, and improves code clarity.
Python Descriptor Protocol: How to Control Attribute Access
Understand the Python descriptor protocol to control attribute access, implement validation, and build reusable attribute logic with __get__, __set__, and __delete__.
Python Descriptors Explained with Practical Examples
python descriptors: Understand the descriptor protocol in Python, how __get__, __set__, and __delete__ control attribute access, and when to use descriptors over @prop...
Python Shallow Copy: What Gets Copied and What Is Shared
Learn how Python's shallow copy differs from assignment and deep copy, where the copy boundary stops, and when each approach is appropriate in real code.
Python List Aliasing: Why Two Names Can Share One List
Understand how Python list aliasing works: assigning a list to a new name shares the same object, and shallow or deep copies can break the alias.
Python Default Argument Evaluation: The Once-Only Trap
python default argument evaluation: Understand why Python evaluates default arguments once at function definition, and how to avoid the mutable default trap.
The Python Mutable Default Argument Problem
Learn why mutable default arguments in Python persist across calls and how the None sentinel pattern prevents shared-state bugs.
Fixing the Python Mutable Default Argument Trap
Python evaluates mutable default arguments once, so a shared list or dict can leak state across calls. Learn the None-sentinel pattern and dataclass default_factory fix.
Python Cyclic References: How to Detect and Break Them
Learn how cyclic references form in Python, how the cyclic garbage collector reclaims them, and how to use weakref to avoid memory leaks in long-running code.
Python weakref: When and How to Use Weak References
Learn how Python's weakref module lets you observe objects without keeping them alive. See when to use weak references and how callbacks, WeakValueDictionary, and WeakKeyDictionary help manage object lifetimes.