Closures and Scope in Python
When I was starting out with Python I introduced a bug into my code because I didn’t understand how scoping works in closures. This is a pretty common pitfall, so here is a post exploring the mistake and how to avoid it. Check out this code: import threading def threaded_print(): for i in range(10): def…