Tagged articles
7 articles
Page 1 of 1
MaGe Linux Operations
MaGe Linux Operations
Jul 15, 2024 · Fundamentals

Why Python’s ‘is’ Returns False for Identical Numbers and Other Gotchas

This article explains why Python’s is operator can yield False for seemingly identical integers, how integer caching and code‑block reuse affect object identity, common pitfalls with re.sub’s count parameter, the character‑based behavior of lstrip, and why list multiplication creates shared references.

Integer cachingPythonis-operator
0 likes · 8 min read
Why Python’s ‘is’ Returns False for Identical Numbers and Other Gotchas
MaGe Linux Operations
MaGe Linux Operations
Jul 2, 2018 · Fundamentals

Why Python Behaves Unexpectedly: 10 Surprising Code Quirks Explained

This article explores ten puzzling Python behaviors—from implicit dictionary key conversion and generator timing quirks to list‑iteration deletions, else clause nuances, the difference between is and ==, loop variable leakage, + versus +=, try‑finally returns, mutable True/False assignments, and subtle for‑loop mechanics—providing clear explanations and code examples for each.

/loopPythondict
0 likes · 11 min read
Why Python Behaves Unexpectedly: 10 Surprising Code Quirks Explained