Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep Windows Console open after a Python Error

File associations on my machine (winxp home) are such that a python script is directly opened with the python interpreter. If I double click on a python script a console window runs and every thing is fine - as long as there is no syntax error in the script.

In that case the console window opens up for a moment but it is closed immediately. Too fast to read the error message.

Of course their would be the possibility to manually open a console window and to execute the script by typing python myscript.py but I am sure that there is a more convenient (i.e. "double click based") solution.

like image 540
cknoll Avatar asked May 16 '10 11:05

cknoll


2 Answers

Make a batch file:

C:\Python26\python.exe %1
IF %ERRORLEVEL% NEQ 0 PAUSE

Use that as your file association instead of python.exe directly. This will only cause the PAUSE statement to execute if python.exe returns an error

like image 50
rossipedia Avatar answered Oct 06 '22 08:10

rossipedia


The canonical way to run a command in a command prompt window that doesn't close is

cmd /k "your command"
like image 26
tzot Avatar answered Oct 06 '22 08:10

tzot