Go to: Na-Rae Han's home page  

Python 3 Notes

        [ HOME | LING 1330/2330 ]

Some Basic Configurations

<< Previous Note           Next Note >>

Change Default File Load/Save Directory for IDLE


Over the years, I have seen students keeping their script files IN THE PYTHON INSTALLATION DIRECTORY. It is such a mess -- they had important system library files and .exe files living next to their personal Python scripts -- hello.py and all!! This is a very bad idea, yet the students kept doing that because, well, IDLE defaulted to the Python installation directory whenever opening or saving files.

So, we must take an extra step to change this setting. That way, IDLE will help you keep your scripts all nice and tidy in your own designated script directory. End goal: get your Python IDLE environment to look like this.

  1. Create shortcut in START
    1. You should first create a shortcut to IDLE by pinning it to the START menu. Look up IDLE, right click, and select "Pint to Start". (Screenshot)
    2. Now an IDLE shortcut is pinned in your START menu. (Screenshot)
  2. Open IDLE shorcut's "Properties" panel
    1. Right-click the IDLE shortcut on START menu.
    2. Choose "More", and then "Open file location." (Screenshot)
    3. You will see many Python shortcuts. Right-click the one for IDLE, and select "Properties". (Screenshot)
    4. "Properties" window will open up. Note the "Start in" directory; it's set to the Python installation directory, and you will need to change that to your own script directory. (Screenshot)
  3. Your own Python script directory
    1. If you haven't done so already, create a folder (anywhere would be fine) where you will keep all your Python scripts. Move all your pre-existing Python scripts into it. Recommendation: a folder called "ling1330" inside your Documents folder.
    2. Open the script directory. On the address bar, click on the address bar, which will reveal the full directory path. Copy the path. (Screenshot)
  4. Edit IDLE shortcut's "Start in" value
    1. Back in the "Properties" window, replace the "Start in:" value with the new directory path by pasting in. (You can also use %HOMEPATH%\Documents which is your default Documents folder.) Again, the Screenshot:
    2. Click "OK".
    3. Restart Python through the shortcut on START. The "File open" (Control+O) dialog now should default to the newly specified directory.
Now, whenever you launch IDLE using this shortcut, you will "start in" your own personal script directory. This has the effect of getting IDLE to default to the directory when opening and saving files (screenshot). Note that this only works when you use the particular shortcut icon on the START menu, which you just configured. If you launch IDLE some other way (for example, through search) it will not behave this way.

Showing File Extensions

Windows OS, ever so helpful, hides away file extensions in the file name. As a result, you see "myscript" instead of "myscript.py", etc. This leads to a lot of confusion while programming -- let's fix it!

Steps:
  1. Open any folder.
  2. Click "View" tab.
  3. Check "File name extensions" in Show/hide menu.