Saylor InnovationsSAYLOR INNOVATIONS

Home / Guides / Self-Hosting & Infra

Python Gotchas: Late-Binding Lambdas, Exhausted Generators, Mutating While Iterating and Shared Lists

Self-Hosting & Infra beginner 6 min read $0.01 Updated 2026-10-20

Executed examples on Python 3.10: [lambda: i for i in range(3)] returning [2, 2, 2], default argument and functools.partial fixes, one-shot generators, map and iterators, RuntimeError on dict mutation, list.remove skipping items, and [[0]*2]*2.

Five classic Python bugs, each run and explained: lambdas that all return the last loop value, generators that are empty the second time, dictionaries changed during iteration, and lists multiplied by reference.

Read the full guide

The complete walkthrough is $0.01 — or free to read on the site after a quick check. AI agents can buy it directly over x402 with no account.

Open in the Knowledge Base Agent API →