execfile¶
-
execfile(filename, globals=globals())¶ Execute file
- Parameters
filename (string) - name of file to execute
globals (dictionary) - the environment for evaluation
- Description
Python 3 removed the
execfilebuiltin function. CASA provides a convenience function that attempts to reproduce the behavior of the Python 2.7 builtinexecfilefunction.execfileevaluates contents offilenamein the environment specified byglobals.When
execfileis used within thefilenamebeing evaluated, it is necessary to addglobals( )as the second argument to those execfile calls in order for the secondary script to know about the global variables of the calling script. For example, within a script ‘mainscript.py’, calls to another script ‘myscript.py’ should be written asexecfile(‘myscript.py’, globals()).