Nov 16, 2024
Posted by:
The IDLE editor which comes packaged with Python is what I consider very suitable for beginners to start with and I generally recommend it for my students. However, right from the start, we must be aware of one perculiar behaviour of IDLE. It defaults to using the Python installation directory for opening and saving files.
As a result many students end up saving their personal Python files into this directory together with all the Python system files. This is a BIG MESS 😒 and we must avoid corrupting the Python system libraries and executable files with our own scripts.
You should put your scripts in your own directory. One way is to navigate to that directory every time you save a file but that is tedious and we should do a one time configuration to change the default directory.
Doing this requires a few steps which are :
The first step is easy. I would recommend to make a folder named python_code in the user folder. You can either use Explorer to do that or use the Command Prompt (or Powershell). If you have not use the Command Prompt (or Powershell) before, now is a good time to get started. See Command prompt for the Python developer. It will become an important skill as you get further along.
To configure IDLE there are a few steps:
In the Properties window, note that the "Start in" directory is by default set to the Python installation directory which is
C:\Users\<yourusername>\AppData\Local\Programs\Python\Python313\
Change this to the directory you have created in your user folder :
C:\Users\<yourusername>\python_code
Click on the Apply button to apply the change and click on OK to close the properties window.
IDLE will now use your own directory as its default.
One last thing we should do is, for convenience, to pin IDLE either to Start or the taskbar, depending on your work preferences. You can also pin to both if you wish.