IDLE is a program that allows you to work interactively with the Python coding environment and is provided by the Python development team. It is included with the Python download at python.org. There are alternative programs to help you write Python code but this one comes free and although a little clunky on the interface it works well. Working with IDLE entails using two windows: the shell and the editor. The first window that appears when you launch IDLE is the “Python Shell” window. This is where Python “runs’ the programs you write. You can work in the shell window. The prompt
indicates where you can start typing and work with Python interactively. For example, you could type:
>>> a = ‘sequence’
to store the assignment of the string ‘sequence’ to the variable ‘a’. Now if you type ‘a’ and press return you should see ‘sequence’ displayed. This is the way of the program to tell you that it has associated the variable ‘a’ with the string of characters. You can use this window to follow the tutorial that comes with your Python installation.
If you choose “New File” from the IDLE “File” menu you will launch a new script editing window. This is where you work on programs. You can open existing scripts (=programs) by choosing “File>Open…”. Once you have an open program that you have written or that you have got from somebody else, you launch it using “Run>Run module”. The advantage of using IDLE over running Python from a Terminal window is that IDLE provides built-in help. The syntax of your program is highlighted by coloring. Note that the program contains both annotation and “live” code. Annotation is any line that is flanked by triple apostrophes: ”’ ”’ and is colored green, and any line that starts with “#” and is colored red. The annotation is there to explain the program or to remind the author or user about the function for each line of code. Any line that is not annotation is code. Green is also assigned to strings in real code lines. Orange defines syntax that is recognized by Python as a command. Black is standard code.
Once you attempt to save and run a program, errors in your code are identified and marked for your attention. This is of great help because you do not want to spend 10 minutes to identify in which line of code you forgot to add a quotation mark or some other silly little thing that is preventing your code from working.
IDLE provides another simplifying help. Suppose that you want to analyze a sequence file and you have written a program to do it. By saving the Python program you wrote ( a file ending in .py) in the same folder as the sequence file, you can avoid using path designations. Your Python module once launched will look in the same folder it resides to find any file you have designated as input. Additionally, it will save any file output in the same folder.