YouTip LogoYouTip

Python Func Execfile

# Python2.x Python execfile() Function [![Image 3: Python Built-in Functions](#) Python Built-in Functions](#) * * * ## Description The execfile() function can be used to execute a file. ### Syntax Here is the syntax for the execfile() method: execfile(filename[, globals[, locals]]) ### Parameters * filename -- The filename. * globals -- The variable scope, the global namespace. If provided, it must be a dictionary object. * locals -- The variable scope, the local namespace. If provided, it can be any mapping object. ### Return Value Returns the result of the executed expression. * * * ## Example The following example demonstrates the use of the execfile function: Assume the file hello.py has the following content: print('tutorial'); ## execfile calls the file >>>execfile('hello.py')tutorial [![Image 4: Python Built-in Functions](#) Python Built-in Functions](#)
← Python Func IsinstancePython Func Eval β†’