Batch file keep window open

broken image

To keep your window open in case of exception (yet, while printing the exception) Python 2 if _name_ = '_main_': That drops you to a python shell after the end of the program, with the program environment loaded, so you may further play with the variables and call functions and methods. I find it particularly useful to configure it as ' python -i myscript.py' when running.

broken image

Other editors allow you to configure the command line it uses to run your program. Some editors prepared for python will automatically pause for you after execution. Specially annoying when testing other people's scripts. That method is annoying because you have to modify the script, and have to remember removing it when you're done. at the end of the script makes it wait for the Enter key. When the program ends, it'll drop you back to the cmd prompt instead of closing the window.Īdd code to wait at the end of your script. Just check on how to edit environment variables on Windows, and add C:\PYTHON26 (or whatever directory you installed python to). Open a command prompt and type: python myscript.pyįor that to work you need the python executable in your path.

broken image

Run the program from an already-open terminal.