code.py
import os import sys import time program = "python3" print("Process calling") arguments = ["xxxxxx.py"] os.execvp(program, (program,) + tuple(arguments)) print("Good Bye!!") time.sleep(5)
xxxxxx.py
print("hahhaha")
python3 code.py
outputs
macname@MacdeMBP files % python3 test.py
Process calling
hahhaha
macname@MacdeMBP files %