Working with Python
The default behavior of double clicking on a Python file actually executes the program as opposed to opening the file. You may see a command line (e.g., Command Prompt or Terminal) opened briefly and quickly closed again when the Python finished executing the file.
Opening
To open and edit the file, you will need to use the IDLE application. There are several ways to do this.
-
IDLE + Open
- Open IDLE.
- Open the file.
-
The shortcut is Ctrl+O (windows) or Cmd+O (mac).
-
-
Right Click
- Right click on the Python file.
- Select the following.
- Windows: Edit with IDLE
- Mac: Open With > IDLE
Double Click to Open
For Windows user, if the instructions above fail, perform the following steps. You are also recommended to try it out to change the default behavior of double click.
- Right click at any Python file.
-
Try one of the two following alternatives.
-
Select "Open With" then click on "Choose another app"
-
Select "Properties" and then on the line with "Opens with:" click on "Change..."
-
-
Scroll down all the way to find "Choose an app on your PC".
-
Type the following on the address bar.
-
There should be a file called
idle.bat
. Select this so that Python files can be opened in IDLE automatically. -
If applicable, click "Apply" to save your changes.
You should be able to open Python file on IDLE by double clicking the file.
Executing
To execute the file from IDLE as opposed to command line, first open the file on IDLE. Then select Run > Run Module. Alternatively, you can press F5.
This will open up IDLE Shell with any print(...)
result printed.