Tag

object-identity

0 views collected around this technical thread.

Raymond Ops
Raymond Ops
Apr 25, 2025 · Fundamentals

Understanding Python’s `is` Operator, re.sub quirks, and list pitfalls

This article explains why Python’s `is` operator yields True or False for integers, how integer caching and code‑block scope affect object identity, uncovers a subtle misuse of re.sub’s count parameter, clarifies lstrip’s character‑wise stripping, and demonstrates the pitfalls of creating nested lists with the `[*] * n` syntax.

Pythonlist-issuesobject-identity
0 likes · 7 min read
Understanding Python’s `is` Operator, re.sub quirks, and list pitfalls
Python Programming Learning Circle
Python Programming Learning Circle
Apr 9, 2020 · Fundamentals

Understanding the Difference Between Python's `is` and `==` Operators and Integer Caching

The article explains how Python's `is` operator checks object identity while `==` checks value equality, illustrates the small‑integer caching mechanism that makes integers from -5 to 256 share the same object, and shows how assignment patterns affect identity results.

Pythonidentityinteger caching
0 likes · 4 min read
Understanding the Difference Between Python's `is` and `==` Operators and Integer Caching
Python Programming Learning Circle
Python Programming Learning Circle
Apr 8, 2020 · Fundamentals

Understanding Python Dictionary Keys, Return Behavior in try/finally, and Object Identity

This article explains why Python dictionary keys with numeric values can overwrite each other, how a return statement inside a try block is overridden by a return in a finally block, and why object identity (is) and hash values behave as they do, illustrating each point with code examples.

dictionaryfundamentalshash
0 likes · 4 min read
Understanding Python Dictionary Keys, Return Behavior in try/finally, and Object Identity