views:

191

answers:

2

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.

+6  A: 

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

Bryan Ross
It looks good. I will try it out tomorrow.
basweber
Hm, nifty! Thanks, Bryan.
Xavier Ho
No problem :) How'd it work for you @basweber?
Bryan Ross
Works like I wanted it. Thanks
basweber
A: 

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

cmd /k "your command"
ΤΖΩΤΖΙΟΥ