Eclipse & Python, as the title suggests. I’m not always elliptical in my references, you know.
I apologise if the title brings back memories of one of the several records with which Jim “I Produced Meatloaf, You Know” Steinman ruined Bonnie “Gravel Is For Gargling” Tyler’s 80s career, but if I have it in my head, I see no reason why it shouldn’t also end up in yours. A problem shared is a problem halved.
Most of my development these days is done in a mixture of Java and Python, each language being used for the tasks for which it is best suited. For a while there, I was doing Java in Eclipse 3.0 and Python in Boa Constructor, but even with 512Mb and not much else open, the laptop was beginning to groan. Eclipse is approximating wonderful, but it eats memory like Americans eat corn-syrup-enhanced snacks. Boa also likes to take up a fair amount of heap, so one of them had to go. It had reached the point at which even partially exposing an Eclipse window after half an hour of ignoring it would slow everything down to a grind for a minute. So I did some digging and discovered that Eclipse does support Python development. Well, support is a relative term; it’s possible, if you’re willing to give up some things, or find workarounds.
First off, how to get Eclipse to handle Python at all. There are at least five Eclipse Python plugins at some stage of development; after some testing (and not a few Eclipse crashes) I chose pydev. The most obvious effect of installing this is that Eclipse recognises .py files and opens them in a Python-aware editor, with the Outline showing a nice list of methods imports and classes, including any if __name__ == ‘__main__’: block (no module-level variables shown, though). The editor follows the Eclipse style of syntax colouring; might not be to your taste, but at least it’s more-or-less consistent between languages.
The most obvious lack is fully-Python-style code completion. Many and better people than I have written on how damn difficult it is to implement this in Python anyway, so I suppose it’s a benefit to get anything. Code completion’s off by default, and the PyDev Preferences tab for it contains dire warnings about how it works and what the drawbacks are. In short, it “executes the code you write on the top level on the module” – I assume this means that it “imports” your code. It looks like code completion’s then done with dir(). There are no tips for parameters to methods or functions, but you do at least get the docstring displayed.
Something else I missed pretty soon – a built-in Python shell. I’ve impressed programmers in other languages before now by flipping between code-in-progress and an interactive shell to test out the statements I’m writing (avoids so many fence-post errors). I’ve always found it especially good for regular expressions. Also, of course, when you’re done coding, you have a bunch of handy test data and statements to hand to build the unit tests. The quickest Eclipse workaround I’ve found is just to keep a Cygwin or Quasi window open running Python and to keep handy with the Windows console cut-and-paste. I suppose SPE or PyCrust would do as well…
PyDev debugging has never worked for me, at all, though this is probably a blessing; meaning I tend to do much more test-driven development. Since there are a bunch of other Python environments around if I really need to step through code, I haven’t bothered to dig into the depths of exactly why the PyDev Debug option never even appears for me. Anyway, most of the Python code runs in Zope, and debugging Zope interactively is just… don’t go there. Really.
A nice touch is that PyDev does it’s best to implement the Eclipse refactoring support, including renaming and extracting code to methods, though there are limitations on how far the renaming search appears to go. Also, it sometimes seems to get slightly confused as to whether the source has changed or not.
Less obvious features: if you have the Subclipse plugin for Subversion integration with Eclipse, it’s now as easy to keep Python scripts and modules under control as it is Java (or any other file). I especially like the ability to check in a set of Java and Python files all together when changes to both are needed to implement some system-wide change. The Eclipse Local History (a sort of “persistent Undo”) also applies to Python scripts.
In short; it’s mature enough to do real serious work with, and the benefits of having all my code in one environment outweight the niggles. After all, there’s no other Python IDE I’ve found that has everything I want in one package, let alone SubVersion integration. In this world we are destined always to strive for perfection and never to find it. I’ll settle for Eclipse & PyDev for the moment.
More info at http://www.python.org/moin/EclipsePythonIntegration