You can literally create any Python application you want using just a text editor. As long as the editor outputs pure text rather than formatted text as a word processor does, you can use it to write Python code. However, using a text editor isn’t efficient or straightforward. To make the development pro- cess easier, developers have written Interactive Development Environments (IDEs). The IDE that comes with Python is IDLE. However, many other IDEs are capable of working with Python.
The feature set provided by IDEs varies. In fact, that’s why there are so many of them on the market. IDLE provides a basic feature set that is shared by most IDEs out there. It provides the functionality required to
- Write Python
- Recognize and highlight keywords and certain types of special
- Perform both simple editing (such as cut, copy, and paste) and code- specific editing (such as showing the parentheses that surround an expression).
- Save and open Python
- Browse the Python path to make locating files
- Browse and locate Python
- Perform simple debugging tasks (removing errors from the code).
IDLE differs from the command-line version of Python in that you get a full- fledged GUI and you can accomplish many tasks much more easily through IDLE than through the command line. In addition, the command line doesn’t really offer all the same features as IDLE. Yes, you can debug your application using the command line, but it’s a difficult, error-prone process. Using IDLE is a whole lot easier.
You find IDLE in the Python 3.3 folder on your system as IDLE (Python GUI). When you click or double-click this entry (depending on your platform), you see the IDLE editor shown in Figure 4-1. The two lines of text contain informa- tion about the Python host and provide suggestions on the commands you can try. The precise information you see differs by platform. Your screen- shots may differ from mine depending on the version of Python you use, the platform you use, how you have IDLE configured, and how you have your system configured.
Figure 4-1: IDLE pro vides you with a GUI
for your application
IDLE provides all the same commands as the command-line version of Python. It doesn’t list them all because the assumption is that you’ll use the GUI features of IDLE to make things easy. However, if you want, you can type help( ) and press Enter to enter help mode, even though this com- mand isn’t listed as one of the initial commands for IDLE as it is for the command-line version. Figure 4-2 shows the results.
Figure 4-2: You can access all the same commands in IDLE that you can with
the com mand line version.
The book doesn’t show the color coding that you see when you type help( ), but you can see it in the editor. Color coding lets you see commands with greater ease and differentiate commands from other sorts of text. Press Enter to get out of help mode. As with the command-line version, you see descrip- tive text each time you perform an action.
Now, type print(‘This is some text.’) and press Enter. You see the expected output, just as you normally would (see Figure 4-3). Notice the color coding, though. The print() command is in purple text to show that it’s a com- mand. The text within the print() command is green to show that it’s data and not a command. The output is shown in blue. The color coding makes things a lot easier, which is just one of many reasons that using IDLE is easier than using the command line.
Figure 4-3: With color coding, you can easily determine the use for each kind of text in an application.