4 ms·
Variables in Python are generally function-scoped instead of block-scoped, because the latter doesn’t work well with implicit variable declarations. However, t
by pansa2 6y ago
Variables in Python are generally function-scoped instead of block-scoped, because the latter doesn’t work well with implicit variable declarations.
However, there are some special cases where variable scope is smaller than a whole function, e.g. within list comprehensions.
- coldtea 6y ago>However, there are some special cases where variable scope is smaller than a whole function, e.g. within list comprehensions. Or we can think of a list comprehension as a function doing a loop/collect under the scenes.