Developer Forums | About Us | Site Map


Useful Lists

Web Host
site hosted by netplex

Online Manuals

Charming Python: Review of Python IDEs
By David Mertz, Ph.D. - 2004-10-26 Page:  1 2 3

Python development made (even) easier

David looks at four open source development environments for working with Python code on Unix-like operating systems. He evaluates two general-purpose editors/environments and two Python-specific ones, and compares the merits of each.

What to look for in a Python IDE

Although I use a number of computers on a daily basis, running OS/2, Linux, FreeBSD, and once every great while Windows, I find that I do an increasing proportion of my work on my PowerBook laptop; I really like the fact that I have a Unix core underlying a polished GUI -- and perhaps I like even more that I can write articles like this one at a local cafe. In my experience, a large proportion of the Python developers I chat with use this same platform. One of the best things about developing on such a Unix-like/X11 environment is that every Python application I create works without changes once uploaded to my Linux-based Web servers or distributed to Linux-based desktop users. (Unfortunately, in my experience, Linux-based laptops still lag behind OS X ones).

I should start with another confession. Even though I have tried out many IDEs for many programming languages, over the years, I always seem to return to using "favorite text editor plus command-line" when I actually want to get something done. It is hard to sell me on form builders, code repositories, structured application templating, code wizards, and all those other things Then again, I wrote a book about text processing -- not about GUI development -- and most of the programming work I have done in my life has been far closer to the former than to the latter.

In this installment, I look at four IDEs/programming editors -- three of them are widely cross-platform (and run well on Linux desktops), one is specific to the Mac. jEdit is a general-purpose editor that runs on any recent JVM. Leo and IDLEfork are themselves written in Python and use Tkinter for their GUI. PythonIDE is part of the MacPython distribution, and runs just on MacOS.

There are a few checklist items that I really want in a Python text editor: syntax highlighting; code folding; autocompletion; sensible indentation behavior; block indent/dedent; block comment/uncomment; an interactive Python shell. A few other things are merely nice to have: class browsers, function jump lists, integrated debugger, and profiler. None of the editors I look at here have screen designers or "drag-and-drop" development.

One editor to rule them all

Even though my subject heading probably insinuates emacs to many readers -- and even though quite a few readers have suggested I look at emacs -- I cannot quite get past the cryptic keystrokes and the like. While I well recognize that emacs does everything, what I am writing this article in is jEdit, an editor that covers a surprisingly wide range of the same goals. jEdit is a GPL project, written in Java, that therefore runs on many platforms; it has bindings and customizations for a great many programming languages; it allows users to create and share macros and "plugins" to enhance the capabilities of the editor. There is nothing very Python-specific about jEdit, but you would hardly notice this, given its nice collection of bindings and plugins for Python.

On the basics, jEdit covers it all. It has good syntax highlighting (in lots of languages), several styles of code folding, and block indent/dedent. Built into jEdit is block commenting (either line-by-line or with begin/end comment delimiters for those languages that use them). There is not any standard shortcut to remove comments from a block, but it would not be hard to write a macro to do so. Actually, in general, the scriptability of jEdit is one of its nicest features.

Figure 1. jEdit with Jython 2.1
jEdit screen capture

You can either record keystroke macros (and assign them to shortcuts), or you can write full Java programs as plugins with arbitrarily sophisticated capabilities. However, I personally have never taken the trouble to learn enough of jEdit's API to write my own plugins (Java is not my forte anyway). Luckily, a lot of smart people have written quite a few plugins for me -- and best of all, installation, removal, and configuration of these plugins is all contained in a friendly interface within jEdit itself (sometimes you will need to restart jEdit for a new plugin to take effect). For example, a handy plugin is the Structure Browser, which shows a collapsible tree of functions, classes, and methods that can be used to navigate or show context within a large module.

Some of the nicest Python-specific functionality for jEdit lies in the Jython plugin. A complete version of Jython is packaged up as a jEdit plugin. Of course, you are stuck at the latest version of Jython itself for this approach, which as of this writing lagged at 2.1 (compared to CPython's recent 2.3 release). Still, if you can live with the Jython version, you can do substantial Python development without leaving jEdit. Beyond the interactive shell you can open, you can also run a Python buffer, with the output appearing either in the interactive shell or in a new buffer (to save for later, perhaps). Little touches like saving an interactive session are also handy.

The features I have mentioned really only scratch the surface of jEdit, since it has similar touches for other languages (particularly for Java, as you might expect) -- and generic "cool" plugins like JDiff or Code2HTML, the former for comparing files, the latter for creating syntax-highlighted HTML.

Even though this is not a Python issue, I feel particularly compelled to mention the many XML features of jEdit. A number of readers of my XML Matters roundups of XML editors (see Resources) suggested I include jEdit -- and, in fact, I often turn to it when I want to edit XML. jEdit's general visual bracket matching is enhanced in XML to recognize corresponding open/close; XPath and XSLT support is included in plugins, as is XML "prettifying."

View Charming Python: Review of Python IDEs Discussion

Page:  1 2 3 Next Page: IDLE Chatter

First published by IBM developerWorks

Copyright 2004-2024 All rights reserved.
Article copyright and all rights retained by the author.