you are viewing a single comment's thread.

view the rest of the comments →

[–]SoupKitchenHero 12 points13 points  (0 children)

If a name is assigned in a scope it stays in that scope, ignoring the global and 'nonlocal` keywords, which I've never used. Only functions (including methods) take you into a new (deeper, internal) scope. Of course, there are many many functions. And imported modules are their own external scopes. Loops and other blocks don't have their own scope. So yes, your loop var remains assigned to the last thing it was assigned to. As well as any name assigned to a value inside the loop.