1

code works fine on IDLE but vs code will open the notepad window then immediately close it

import subprocess as sp
programme = "Notepad.exe"
fileName = "nerd.txt"
sp.Popen([programme,fileName])
  • My guess is IDLE is running as a [REPL](https://en.m.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop), so when you issue that last statement, your Python program is still running & waiting to execute the next statement you give it; whereas VS Code runs it as a normal program, so it exits immediately after it successfully runs the last line, thus killing the Notepad child process. Try adding a [press enter to continue](https://stackoverflow.com/questions/983354/how-to-make-a-script-wait-for-a-pressed-key) line at the end to keep the Python program alive. – Noah Jul 03 '21 at 14:12

0 Answers0