Python execfile() Function
Description
The execfile() function can be used to execute a file.
Syntax
The syntax of the execfile() method is as follows:
execfile(filename[, globals[, locals]])
Parameters
- filename -- the file name.
- globals -- the variable scope and global namespace; if provided, it must be a dictionary object.
- locals -- the variable scope and local namespace; if provided, it can be any mapping object.
Return Value
Returns the result of expression execution.
Example
The following examples show the use of the execfile function:
Suppose the file hello.py has the following content:
print('runoob');
execfile calls this file
execfile
(
'
hello.py
'
)
runoob
Python built-in function