os execl

Solutions on MaxInterview for os execl by the best coders in the world

showing results for - "os execl"
Fátima
06 Jan 2021
1import os
2import sys
3
4restart = input("\nDo you want to restart the program? [y/n] > ")
5
6if restart == "y":
7    os.execl(sys.executable, os.path.abspath(__file__), *sys.argv) 
8else:
9    print("\nThe program will be closed...")
10    sys.exit(0)
11
Alessandro
17 Jun 2016
1import os
2import sys
3
4if(input("Would you like to restart?\n") == "y"):
5    os.execl(sys.executable, 'python', '"{}"'.format(__file__), *sys.argv[1:])
6else:
7    exit(0)