See All Titles |
![]() ![]() Editing CodeAs you already know, Python provides two development environments that offer a lot of useful features which can help you while coding: Pythonwin and IDLE. However, for simple programs, or in case you don't have a graphical environment available, you can stick to simple text editors that can be used to handle the job very nicely. On Windows systems, you can use editors such as Editpad and Notepad to write Python scripts; on DOS systems, EDIT, and on UNIX systems you have choices such as Pico, Vi, Emacs, and others. Pico is a full screen editor that is reasonably intuitive. Pico's commands can be learned in just some minutes and Pico itself is good for editing small texts with just a few changes. However, you need commands that are more powerful when a text becomes bigger because Pico only has a limited number of commands. These commands are shown at the bottom of the editing screen. Also note that Pico makes limited use of mice. Pico is not 100% recommended for Python programming because it wasn't designed as a programmer's editor. It does things such as automatic word wrap, which might not be what you want. Vi (visual editor) is another full screen editor that was seen as a big improvement over line editing. Vi is highly customizable, allows filtering, has number prefixes for commands, has an invocation of a shell, has better jump commands, can read in the result of external commands, save parts of text, substitute literal strings and regular expressions, and many other options. The vi clone vim (vi improved) can be scripted in Python among other languages. JED is a freely available text editor for UNIX, VMS, MSDOS, OS/2, and MS Windows. This editor has many features, including drop-down menus, folding support, color syntax highlighting on color terminals, and emulation of Emacs, EDT, Wordstar, and Borland editors. It's said that the latest version of the JED editor has a Python mode, with many of the same features as the Emacs/XEmacs Python mode. See its Web page for more information: http://space.mit.edu/~davis/jed.html Vi, Pico, and JED are certainly powerful editors. However, Emacs is quite a jump in feature variety. Emacs is a very extensible and customizable editor. The richness of Emacs makes it more difficult to learn, but it is worth the try. A version of Emacs called XEmacs (which is a very famous implementation) can also be used for writing Python programs. EmacsEmacs originally was an acronym for Editor MACroS. The heart of Emacs is an interpreter for elisp (Emacs Lisp), which is a dialect of the Lisp programming language with extensions to support text editing. Currently, Emacs is much more than a text editor. Besides allowing you to edit several styles of source codes and other general-purpose files, it contains many extensions that provide support for features such as Web browsing and mail reading. Emacs is a GNU project, and it is maintained by the Free Software Foundation. Some of the features of Emacs include
Check out the GNU Emacs Web site for details: http://www.gnu.org/software/emacs/ Note
XEmacs is a highly customizable open source text editor and application development system, which is based on GNU Emacs, and shares a lot of code with it. XEmacs is protected under the GNU Public License, and its emphasis is on modern graphical user interface support and an open software development model. XEmacs has an active development community and runs on Win32 and UNIX platforms. See http://www.xemacs.org/ for details. Emacs has its own section on the Python Web site, precisely at the following address: At that page, you can find a collection of links to several Emacs codes that might help with your Python programming. Most of the code works fine on top of the latest versions of both Emacs and XEmacs. From that page, you can also get access to some Emacs modes that enable the coding of Python source code when using Emacs, such as the Python Mode, located at http://www.python.org/emacs/python-mode/ You might want to byte-compile that python-mode file when installing it on your system, primarily for better performance. To do so, you need to open Emacs (or XEmacs) and execute the following commands. Note that you can safely ignore any byte compiler warnings. C-x C-f /path/to/python-mode.el RET M-x byte-compile-file RET On the Web site, besides getting access to the latest release of the python-mode (the current version is 3.105), you can also obtain other useful stuff, which includes: a detailed list of changes since the last released version, installation notes, a FAQ, and a Emacs/XEmacs compatibility details list, which brings special notes about Emacs/XEmacs versions and package interactions. To install the python-mode package so that it can be used in Python, you would put it in the site-lisp directory, and edit your site-start.el to autoload python-mode.el and bind it to .py files. The following links provide additional information related to the usage of Emacs/XEmacs along with Python.
http://www.beopen.com/manuals/alt-oobr-cover.html
http://www.python.org/workshops/1996-06/papers/h.pasanen/oobr_contents.html
http://bigbear.pc.helsinki.fi/harri/
|
© 2002, O'Reilly & Associates, Inc. |