python execute file

import fileB #Replace fileB with the apportite file name
fileB.my_func() #Can replace 'my_fun' with a function from the second .py file
execfile('') #Executes the .py file

Here is what the above code is Doing:
1. It’s importing the fileB module into the current namespace.
2. It’s calling the my_func function from fileB.
3. It’s executing the script.

Note that when you use the import statement, it searches for the module in the directory which the script was executed.