Browse by Topic

Popular

Latest

Latest Python Posts

Illustration of a mutable list and an immutable tuple, with a lock symbol on the tuple indicating hashability.
Python

Python Mutable vs Hashable: What Every Developer Should Know

Understand why mutable built-in types are not hashable in Python, how hashability affects dict keys and set membership, and when to override __hash__ and __eq__ in custom classes.

PythonHashableMutableDictionary
Illustration of Python hashable types showing a dictionary and set with a hash function symbol
Python

Python Hashable Types: Dict Keys and Set Members

Learn what makes a Python type hashable, why dictionary keys and set members require it, and how to implement __hash__ and __eq__ correctly.

hashabledict keysset membership__hash__
Illustration of immutable data types in Python showing a locked box with data inside, representing unchangeable objects.
Python

Understanding Python Immutable Data Types

python immutable data types: Learn how Python's immutable data types behave, why they matter for memory and concurrency, and how to build custom immutable objects.

immutabilitypython-typesmemory-managementconcurrency
Diagram showing two variables referencing the same mutable list object, with a mutation symbol indicating in-place change.
Python

Python Mutable Data Types: Behavior and Pitfalls

Learn how Python's mutable data types behave, why assignments and function calls can cause surprising side effects, and how to copy lists, dictionaries, and sets correctly.

PythonMutableImmutableAliasing
Diagram contrasting a mutable list object whose contents change in place with an immutable string object that creates a new value on modification.
Python

Python Mutable vs Immutable Types: Behavior and Tradeoffs

Explains how Python's mutable and immutable types differ in assignment, aliasing, hashing, and memory behavior, with practical code examples and guidance for choosing the right type.

PythonMutable ObjectsImmutable ObjectsData Types
Illustration comparing Python type() and isinstance() functions with inheritance hierarchy.
Python

Python type vs isinstance: When to Use Each

Understand the practical difference between Python's type() and isinstance(), including inheritance behavior, protocol checks, and when to use each.

Pythontype checkingisinstanceduck typing
Illustration of a Python code snippet showing isinstance type checking with a class hierarchy and a checkmark indicating a valid type match.
Python

Using isinstance in Python for Runtime Type Checks

python isinstance: Learn how isinstance works in Python, when to use it over type(), how inheritance affects results, and where runtime type checks are appropriate.

Pythonisinstancetype checkinginheritance
Illustration of Python's type() function showing an object being inspected and a class being created dynamically.
Python

Python type() Function: Runtime Type Inspection and Dynamic Classes

Learn how Python's type() function inspects object types and creates classes dynamically, and when to prefer isinstance() for robust type checking.

type()runtime type checkingisinstancedynamic classes
Diagram showing Python None as a singleton object with identity checks and type hints.
Python

Python None Type: Behavior, Pitfalls, and Best Practices

Understand Python's None type: singleton behavior, is None comparisons, Optional type hints, and common pitfalls like mutable default arguments.

NonePythonType HintsOptional
Illustration of a Python dictionary mapping keys to values with type annotations.
Python

Python Dict Type: Syntax, Typing, and Performance

Learn how the Python dict type works at runtime, how to annotate dicts with type hints, and when to choose another data structure.

Pythondicttype hintsdata structures