<DIV>hello friends, the question had show bellow, any friend can tell me why. thanks.</DIV>
<DIV> </DIV>
<DIV>list:</DIV>
<DIV>def test():<BR>  exec "import sys"<BR>  a=range(15)<BR>  b=[13,3]<BR>  c=filter(lambda x: x not in b,a)<BR>  return c</DIV>
<DIV>print test()</DIV>
<DIV> </DIV>
<DIV>run result:</DIV>
<DIV>  File "a.py", line 2<BR>    exec "import sys"<BR>SyntaxError: unqualified exec is not allowed in function 'test' it contains a nested function with free variables</DIV>
<DIV> </DIV>
<DIV>and must be change to bellow, then OK:</DIV>
<DIV>b=None</DIV>
<DIV>def testFilter(x):</DIV>
<DIV>  global b</DIV>
<DIV>  return x not in b</DIV>
<DIV>
<DIV>def test():<BR>  exec "import sys"</DIV>
<DIV>  global b<BR>  a=range(15)<BR>  b=[13,3]<BR>  c=filter(testFilter,a)<BR>  return c</DIV>
<DIV>print test()</DIV> </DIV>
<DIV>last run result is:</DIV>
<DIV>[0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14]</DIV>
<DIV> </DIV>
<DIV>any friend can tell me why?</DIV>
<DIV>thanks alot very much!!</DIV>