This is how its supposed to work.
When you "doubleclick" the .py
file windows sees an executable file and invokes a cmd-shell and runs your python executable within (even though its only a text file, its considered as an executable - thats how you have set it in your system - this can be changed, say to make a doubleclick simply open the file in a text editor of your choice, like Notepad or Notepad++ or Python's default IDLE editor). Since division by 0 is an error, the cmd-shell is killed as soon as the error is seen in the .py
file - your .py
file is treated as an executable, much like how an .exe
application crash doesn't wait for you before its killed.
If you do not want lose the window and wish to see the error, then you already seem to know what to do - run it by invoking python from a cmd-shell manually, or better still, use the built-in IDLE editor (Press F5 to run your script from an IDLE editor)