"Attila Szabo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I wrote this sample piece of code: > > def main(): > lambda x: 'ABC%s' % str(x) > for k in range(2): exec('print %s' % k) > > main() > > With the lambda line, I get this: > SyntaxError: unqualified exec is not allowed in function 'main' > it contains a nested function with free variables
The lambda expression is the nested function, the free variable is 'str'. Since this general situation *could* be a problem, as Scott explained, the compiler quits, since it cannot do the analysis needed to determine whether the specific situation *is* a problem. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list