Module Import alias alias alias Print Str Call NameLoad Str Print Str Call NameLoad Str FunctionDef arguments args defaults body Return Call NameLoad Str decorator_list Print Str Call NameLoad FunctionDef arguments args defaults body Assign NameStore ListLoad Num Assign NameStore Dict Assign NameStore Call NameLoad Str NameLoad Return TupleLoad NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list Print Str Call NameLoad FunctionDef arguments args defaults body Assign NameStore ListLoad For NameStore Call NameLoad Str body Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list Print Str Call NameLoad Print Str Exec Str Print Str NameLoad FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Str Exec NameLoad Return NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Str Exec NameLoad Call NameLoad Call NameLoad Return NameLoad decorator_list Print Str Call NameLoad Call NameLoad Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad NameLoad Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad Print Str NameLoad NameLoad Assign NameStore Dict Str Str Str Num Assign NameStore Call NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad Print Str Call AttributeLoad NameLoad attr Expr Call NameLoad NameLoad NameLoad NameLoad Print Str NameLoad FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Num Assign NameStore Dict Str Str Str Num Assign NameStore Call NameLoad NameLoad Print Str Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Print NameLoad Print Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list Expr Call NameLoad ClassDef bases body Assign NameStore Num Assign NameStore Num Print Str Expr Call NameLoad NameLoad Print Str NameLoad NameLoad decorator_list Assign NameStore Num FunctionDef arguments args defaults body Assign NameStore Num Exec Str NameLoad NameLoad Print Str NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Num Exec Str NameLoad NameLoad Print Str NameLoad decorator_list Expr Call NameLoad Expr Call NameLoad Print Str NameLoad FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Str Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Print Str NameLoad decorator_list Expr Call NameLoad FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Str Assign NameStore NameLoad Assign NameStore NameLoad Exec NameLoad NameLoad NameLoad Print Str NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Str Assign NameStore NameLoad Assign NameStore NameLoad Exec NameLoad NameLoad NameLoad Print Str NameLoad decorator_list Expr Call NameLoad Expr Call NameLoad Print Str Exec Str Exec Str Assign NameStore Num Assign NameStore Num FunctionDef arguments args defaults body Global identifier Print Str NameLoad Assign NameStore Num Print Str NameLoad Print Str Call NameLoad Exec Str Print Str NameLoad Exec Str Print Str Call NameLoad Exec Str Print Str NameLoad Exec Str FunctionDef arguments args defaults body Global identifier Print Str NameLoad decorator_list Expr Call NameLoad Print Str NameLoad decorator_list Expr Call NameLoad FunctionDef arguments args defaults body Assign NameStore Str Exec NameLoad NameLoad NameLoad FunctionDef arguments args defaults body Print Str NameLoad decorator_list Expr Call NameLoad decorator_list Expr Call NameLoad Assign NameStore Num FunctionDef arguments args defaults body Assign NameStore Num Assign NameStore Str Assign NameStore Call NameLoad Exec NameLoad NameLoad FunctionDef arguments args defaults body Return NameLoad decorator_list Return TupleLoad NameLoad Call NameLoad decorator_list Print Str Call NameLoad FunctionDef arguments args defaults body Expr Yield Num Assign NameStore Str Exec NameLoad Expr Yield NameLoad decorator_list Print Str Call NameLoad Call NameLoad FunctionDef arguments args defaults body Assign NameStore Call NameLoad GeneratorExp Call NameLoad Call NameLoad NameLoad comprehension NameStore Call NameLoad Num Assign NameStore ListComp Call NameLoad Call NameLoad NameLoad comprehension NameStore Call NameLoad Num Return TupleLoad NameLoad NameLoad decorator_list Print Str Call NameLoad FunctionDef arguments args defaults body Exec Str Call NameLoad If CompareLt AttributeLoad NameLoad attr TupleLoad Num body Assert NameLoad Return Str decorator_list Print Str Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad FunctionDef arguments args defaults body TryExcept body Exec TupleLoad Str handlers ExceptHandler type NameLoad name NameStore body Return BinOpAdd Str Call NameLoad NameLoad decorator_list Print Str Call NameLoad
N/A N/A tempfile sys os N/A eval 3+3= N/A eval 3+3 N/A eval  4+4= N/A eval  4+4 functionEval1 N/A N/A N/A N/A N/A N/A eval  5+5 N/A N/A eval in a function with nothing provided N/A functionEval1 functionEval2 N/A N/A N/A N/A N/A a N/A 2 N/A g N/A N/A r N/A eval 1+3 g N/A N/A r N/A N/A g keys a N/A N/A eval in a function with globals provided N/A functionEval2 functionEval3 N/A N/A N/A N/A N/A result N/A N/A x N/A eval (1,2) N/A N/A N/A N/A result append x N/A result N/A N/A eval in a for loop as iterator giver N/A functionEval3 N/A exec on a global level N/A d=2+2 N/A 2+2= d functionExec1 N/A N/A N/A N/A N/A a 1 N/A code a=2 N/A code N/A a N/A functionExec2 N/A N/A N/A N/A N/A a 1 N/A code a=2 N/A code N/A globals N/A locals N/A a N/A N/A exec in function without and with locals() provided: N/A functionExec1 N/A functionExec2 N/A tmp_filename N/A N/A N/A tempfile gettempdir /execfile.py N/A f N/A open tmp_filename w N/A N/A N/A f write e=7
f=8
 N/A N/A N/A f close N/A N/A execfile tmp_filename N/A execfile with defaults f,g= e f N/A global_vars N/A e f 0 0 N/A local_vars N/A dict global_vars N/A N/A execfile tmp_filename global_vars N/A execfile with globals dict: N/A N/A global_vars keys N/A N/A execfile tmp_filename global_vars local_vars N/A execfile with globals and locals dict: local_vars functionExecfile N/A N/A N/A N/A N/A e 0 N/A f 0 N/A global_vars N/A e f 0 0 N/A local_vars N/A dict global_vars N/A execfile with globals and locals dict in a function: N/A x N/A execfile tmp_filename global_vars local_vars N/A x N/A N/A N/A global_vars keys local_vars e f N/A N/A N/A functionExecfile classExecfile N/A N/A N/A e 0 N/A f 0 N/A execfile in a class: N/A N/A execfile tmp_filename N/A execfile changed local values: e f N/A N/A f 7 functionExecNonesTuple N/A N/A N/A N/A N/A f 0 N/A f=1 None None N/A Exec with None as optimizable tuple args did update locals: f N/A functionExecNonesSyntax N/A N/A N/A N/A N/A f 0 N/A f=2 None None N/A Exec with None as optimizable normal args did update locals: f N/A N/A N/A functionExecNonesTuple N/A N/A functionExecNonesSyntax N/A Global value is untouched f functionEvalNones2 N/A N/A N/A N/A N/A f 11 N/A code f N/A g None N/A l None N/A f1 N/A eval code l g N/A Eval with None arguments from variables did access locals: f1 N/A N/A N/A functionEvalNones2 functionExecNonesTuple2 N/A N/A N/A N/A N/A f 0 N/A code f=1 N/A g None N/A l None N/A code l g N/A Exec with None as tuple args from variable did update locals: f N/A functionExecNonesSyntax2 N/A N/A N/A N/A N/A f 0 N/A code f=2 N/A g None N/A l None N/A code l g N/A Exec with None as normal args did update locals: f N/A N/A N/A functionExecNonesTuple2 N/A N/A functionExecNonesSyntax2 N/A Exec with a future division definition and one without: N/A 
from __future__ import division
from __future__ import print_function
print( "3/2 is with future division", 3/2 )
 N/A 
from __future__ import print_function
print( "3/2 is without future division", 3/2 )
 N/A x 1 N/A y 1 functionGlobalsExecShadow N/A N/A N/A N/A N/A x N/A Global x outside is x N/A y 0 N/A Local y is initially y N/A Locals initially N/A locals N/A 
from __future__ import print_function
x = 2
print( "Exec local x is", x )
 N/A Function global x referenced as local x in exec is x N/A 
from __future__ import print_function
print( "Re-exec local x", x )
 N/A Locals after exec assigning to local x N/A locals N/A 
from __future__ import print_function
global x
x = 3
print( "Exec global x is inside exec", x )
 N/A Global x referenced as global x in exec is x N/A 
from __future__ import print_function
def change_y():
   global y
   y = 4

   print( "Exec function global y is", y )

y = 7
change_y()

# TODO: The below will not work
print( "Exec local y is", y )
 print_global_y N/A N/A N/A N/A N/A y N/A Global y outside y N/A N/A N/A print_global_y N/A Outside y y N/A N/A N/A functionGlobalsExecShadow functionWithClosureProvidedByExec N/A N/A N/A N/A N/A code ValueError = TypeError N/A code None None func N/A N/A N/A N/A N/A Closure from exec not used ValueError N/A N/A N/A func N/A N/A N/A functionWithClosureProvidedByExec N/A x 2 functionWithExecAffectingClosure N/A N/A N/A N/A N/A x 4 N/A code d=3;x=5 N/A space N/A locals N/A code space closureMaker N/A N/A N/A N/A N/A x N/A N/A N/A d N/A closureMaker N/A N/A Closure in a function with exec to not none N/A functionWithExecAffectingClosure generatorFunctionWithExec N/A N/A N/A N/A N/A N/A 1 N/A code y = 2 N/A code N/A N/A y N/A N/A Exec in a generator function N/A tuple N/A generatorFunctionWithExec evalInContractions N/A N/A N/A N/A N/A r1 N/A list N/A N/A eval N/A str s N/A s N/A range 3 N/A r2 N/A N/A eval N/A str s N/A s N/A range 4 N/A N/A r1 r2 N/A N/A Eval in a list contraction or generator expression N/A evalInContractions execDefinesFunctionToLocalsExplicity N/A N/A N/A N/A N/A def makeAddPair(a, b):
    def addPair(c, d):
        return (a + c, b + d)
    return addPair
 N/A locals N/A N/A N/A sys version_info N/A 3 N/A N/A makeAddPair N/A yes N/A N/A Exec adds functions declares in explicit locals() given. N/A execDefinesFunctionToLocalsExplicity N/A N/A N/A os unlink tmp_filename execWithShortTuple N/A N/A N/A N/A N/A N/A N/A N/A print hey N/A N/A N/A Exception N/A e N/A N/A N/A gives exception:  N/A repr e N/A N/A Exec with too short tuple argument: N/A execWithShortTuple