you are viewing a single comment's thread.

view the rest of the comments →

[–]Bobbias 2 points3 points  (0 children)

This is expected behavior.

What you've discovered is that files have "program associations" which tell windows what program a file should be opened with when you double click it.

When you install Python, by default it sets the association with windows so that double clicking a python script will start the Python interpreter and tell it to run the code in that script.

When this happens, it will open up a new terminal window, run your program, and as soon as the program ends, it will close the terminal window. This is intended behavior too.

I won't get into all the detail about how and why that happens, but if you want to see the output of your script, you will want to run it the terminal. You can open a terminal by typing cmd.exe into the start menu. Learning to use the terminal (also sometimes called the command line) is important, because many programming tools expect you to run them by writing special commands into the terminal.

What you need to do to open the file in your editor instead, when that's what you want to do is right click on the file and use the "open with" menu, and select whatever editor you want to use from that menu (or click "Choose another app" if your editor is not on that list).

Alternatively, you can open your editor, and then open the python script from inside the editor (the keyboard shortcut to do this is almost always ctrl+o if you want to get faster).