Skip to content

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

    1. Open IDLE.
    2. Open the file.
      • The shortcut is Ctrl+O (windows) or Cmd+O (mac).

        Open

  • Right Click

    1. Right click on the Python file.
    2. 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.

  1. Right click at any Python file.
  2. Try one of the two following alternatives.

    • Select "Open With" then click on "Choose another app"

      OpenWith

    • Select "Properties" and then on the line with "Opens with:" click on "Change..."

      Properties

  3. Scroll down all the way to find "Choose an app on your PC".

    SelectApp

  4. Type the following on the address bar.

    %localappdata%\Programs\Python\Python312\Lib\idlelib
    

    Address

  5. There should be a file called idle.bat. Select this so that Python files can be opened in IDLE automatically.

    IDLEbat

  6. 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.

Run

This will open up IDLE Shell with any print(...) result printed.

Run02