Jul-17-2019, 02:46 AM
Please explain why this doesn't work
seq=[1,2,3] def a(): return x+2 x=[a() for x in seq]I thought a list comprehension create a new local scope for the expression itself, and when we use a(), x is searched by the LEGB rule and can find the x in the enclosing scope, am i correct ?