[Python] How to execute another python file and then close the existing one?

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a program that requires to call another python script and truncate the execution of the current file. I tried doing the same using the os.close() function. As follows:

    def call_otherfile(self):
    os.system("python file2.py") #Execute new script
    os.close() #close Current Script


    Using the above code I am able to open the second file but am unable to close the current one.I know I am silly mistake but unable to figure out what's it.

    Continue reading...

Compartilhe esta Página