How can I make one Python file run another?

There are multiple ways to make one Python file run another.

1. Use it like a module. import the file you want to run and run its functions. For example, say you want to import into, assuming the files are in the same directory, inside fileA you'd write

import fileB

Now in fileA, you can call any function inside fileB like:


2. You can use the exec command. 


 executes the file in the interpreter.

3. You can spawn a new process using the os.system command.

For example