News for hackers. Stuff that matters.
Re:What Is the Switch-Case Equivalent in Python? by pansa2 on Sunday April 04, 2021 @03:20AM (#26687542)
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.

Re:What Is the Switch-Case Equivalent in Python? by coldtea on Sunday April 04, 2021 @04:02AM (#26687691)
>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.