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.

Pythoninteger cachingis-operator
0 likes · 8 min read
Why Python’s ‘is’ Returns False for Identical Numbers and Other Gotchas
MaGe Linux Operations
MaGe Linux Operations
Jun 3, 2019 · Fundamentals

7 Common Python Pitfalls Explained with Code Examples

This article walks through seven tricky Python snippets—default mutable arguments, lambda closures, class variable inheritance, division differences between Python 2 and 3, out‑of‑range slicing, list multiplication side effects, selective list comprehensions, and custom dict subclasses—explaining their outputs and how to fix them.

Class Variablesclosuresdefault-arguments
0 likes · 12 min read
7 Common Python Pitfalls Explained with Code Examples