Default Python IDE
Foreword
A tutorial about how to use the default Python IDE called IDLE.
Installing Python
Our first step is to install Python. Therefore we visit the official Python Website, navigate to Download and download a Python version. There are two options right now:
- Python 3: contains a new concepts, is faster than Python 2.
- Python 2: is simpler than Python 3.
We love simplicity, so we will go for Python 2. The Python developers are still updating Python 2 regularly, so we will do just fine with it.
Now that we know which Python version we want to use, we will download the Python 2.x.x Windows installer from the Python Download Page:
As soon as the download is finished, we simply install it.
Now our computer knows how to execute Python code, great!
Starting IDLE
The default graphical development environment for Python is IDLE. IDLE comes with the Python installation, so all we have to do is open it.
There are several ways to start IDLE. For example, on Windows we could hit the Start button, go to Programs, then click on Python 2.7 and then select IDLE (Python GUI). Alternatively we can also go to our Python install path and run IDLE manually by double clicking the 'idle.bat' file in C:/Python27/Lib/idlelib or wherever we have installed Python before.
We are now greeted with the Python Shell Window:
Playing around with the Shell
The shell is a very useful utility, it's pretty much like a sandbox where we can try things out quickly.
For example, let's find out what 1 + 1 is:
Let's try one more thing and find out what happens if we sort the list [3, 1, 2]:
The Python shell allows us to test things without saving files, without building, without linking and without compilation delays. We don't have to use it, but there is a lot of value in it when it comes to testing.
Creating a Module
Now let's get to the important part. We will create a new Python file, write some code into it and then run it. This is very easy, all we have to do is select File -> New Window and now we have two windows open:
The top window is our new file, and the bottom window is still the Python shell.
So let's put something into our file:
Now before we can run it, we still have to save it. Therefore we go to File -> Save and save it somewhere as 'test.py'.
Afterwards all we have to do to run it is press F5 or click on Run -> Run Module. Now we can see the result in the shell:
And that's all there is to it. We just open IDLE, create a new file, put our code in there and run it. The result always shows up in the shell window.