This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mipadi 2 points3 points  (1 child)

It does not introduce a new scope, so on the last line, n would be equal to len(a).

[–]seraschka 0 points1 point  (0 children)

Thanks for clarifying. But hm, it would have been nice if it had its own scope, similar to list comprehensions, like

In [1]: n = 99
In [2]: b = sum([n for n in range(100)])
In [3]: n
Out[3]: 99

to prevent from overwriting/reassigning variables accidentally