This section lists some additional tools which are popular ways to
create, maintain and execute Python programs. While IDLE is suitable for
many purposes, you may prefer an IDE with a different level of
sophistication.
The Komodo Edit is an IDE that is considerably more sophisticated
than IDLE. It is — in a way — too sophisticated for this book. Our focus
is on the language, not high-powered IDE's. As with IDLE, this is a tool
that runs everywhere, so you can move seamlessly from GNU/Linux to
Wiundows to the Mac OS with a single, powerful tool.
See www.komodo.com for more
information on ordering and downloading.
Windows programmers might want to use a tool like
Textpad. See www.textpad.com for information on
ordering and downloading. Be sure to also download the
python.syn
file from www.textpad.com/add-ons,
which has a number of Python syntax coloring configurations.
To use Textpad, you have two setup
steps. First, you'll need to add the Python document class. Second
you'll need to tell Textpad about the Python
tool.
The Python Document Class. You need to tell Textpad about the
Python document class. Use the menu; the
menu item lets you add
Python documents to Textpad. Name your new
document class Python
and click
Next. Give your class members named
*.py
and click Next.
Locate your python.syn
file and click
Next. Check the new Python document class, and
click Next if everything looks right to create
a new Textpad document class.
The Python Tool. You'll want to add the Python interpreter as a
Textpad tool. Use the
menu again, this time selecting the
item. Scroll down the list of
preferences on the left and click on Tools. On
the right, you'll get a panel with the current set of tools and a
prominent Add button on the top right-hand
side. Click Add, and select
from the menu that appears. You'll
get a dialog for locating a file; find the
Python.exe
file. Click
Okay to save this program as a
Textpad tool.
You can check this by using menu and
item again. Scroll down the list
to find Tools. Click the +
sign and open the list of tools. Click the Python
tool and check the following:
- The Command is the exact path to your copy of
Python.exe
- The Parameters contains
$File
- The Initial Folder contains
$FileDir
- The “capture output” option should be
checked
You might also want to turn off the Sound Alert option; this will
beep when a program finishes running. I find this makes things a little
too noisy for most programs.
Macintosh programmers might want to use a tool like
BBEdit. BBEdit can
also run the programs, saving the output for you. See www.barebones.com for more
information on BBEdit.
To use BBEdit, you have two
considerations when writing Python programs.
You must be sure to decorate each Python file with the following
line: #!/usr/bin/env python
. This tells
BBEdit that the file should be interpreted by
Python. We'll mention this again, when we get to script-writing
exericses.
The second thing is to be sure you set the “
chdir
to Script's Folder
” option when you use the the
item in the
(“shebang”) menu. Without this, scripts are run in the root
directory, not in the directory that contains your script file.