InfoWorld review: Nine fine Python development tools

A wide-ranging flock of Python IDEs offer great options for Windows scripting, GUI applications, Web frameworks, multilanguage development, and more.

1 2 3 4 5 6 7 8 9 10 11 Page 9
Page 9 of 11

Nine fine Python development tools: Spyder
Spyder is another Python IDE written in Python. It has been verified to run on Windows, Mac, and Linux.

Spyder is really a kind of numerical package that just happens to use Python as its scripting language. In fact, Spyder's creator, Pierre Raybaut, purposefully incorporated features in Spyder to make its behavior similar to MATLAB's and designed the Spyder workspace to look like MATLAB. Spyder requires PyQt, and at least PyQt4. To use Spyder as it is really intended, you should also download and install pylint, NumPy, SciPy, and matplotlib.

The version I tested was 1.0.3. I used Python 2.6 in my testing, though Spyder's creator informed me that Spyder should work with Python 3.1, and he had reports of users running Spyder in a 3.x-level Python. However, he indicated that, for scientific and mathematical users, there is little different between Python 2.x and Python 3.x. In addition, as of this writing, NumPy and SciPy had not been ported to Python 3. (The development version of NumPy supports Python 3, and a release version is expected in the fall.)

Spyder has three startup levels: All, Basics, and Light. The startup level controls which components are imported when the IDE loads. All imports everything: the math libraries, os, sys, re, time, and os.path. Basics imports the math libraries only, and Light turns off all the add-ons. If you start the Light version, Spyder will not have access to NumPy, SciPy, and matplotlib, though you can manually import those libraries via Spyder's interactive console at a later time.

Spyder's interactive console opens automatically in a pane on the right-hand side of the IDE. Not only can you enter Python code, but the console will accept shell commands if you precede an entry line with !. For example, to get a local directory, enter !dir. The console also provides a history log of past commands, available within a separate tab. Select the tab, and you can cut and paste entries from the past.

Spyder also provides an object inspector that executes in the context of the console. Any objects created in the console can be examined in the inspector. More interesting, though, is the workspace view, which appears at first glance to be a kind of global variable browser for the interactive console, showing all global variables defined in the console, as well as their data type, size, and value.

Right-click on a global variable's value field in the workspace, and a pop-up menu appears. Some of its selections are obvious, such as duplicate and delete. Others are not so obvious. You can, for example, select Plot for either Python or NumPy numeric arrays, and a line graph is displayed for the data. Or you can select Show Image for a 2D numeric array, and Spyder will display a pseudo-color representation of the array -- which is completely cool if you're not expecting it.

You can launch object specific editors from within the console. Just enter oedit(<obj>) and a GUI editor will open, allowing you to edit the contents of <obj> where <obj> can be a list, a tuple, a str, or a numpy.array of one or two dimensions. It's important to realize, though, that oedit() does not edit the object in place. To have your changes stick, you must instantiate a new object and place the output reference of the oedit() call into this new object.

Spyder's editor supports multiple languages, with color coding for syntactic elements of C, C++, and Fortran. The reason for this capability derives from Spyder's origin as a development platform for science and math. Extensions to Python are often written in C/C++ and Fortran; in fact, much of NumPy's calculation core is written in C. The multilanguage support allows developers to at least create the source for extensions without leaving the Spyder environment.

The editor does provide rudimentary code completion. Enter an object, follow with a . (a period), and Spyder will pop up a list of allowed methods. Begin typing a method and another pop-up appears, listing the allowed arguments and data types as well as the method's return type. You can also run the PyFlakes lint-like tool on your source; PyFlakes locates a number of common syntax errors in the source.

Unfortunately, there is not much in the documentation about debugging. Also, while there are more than a half-dozen different Run variants (Run in interactive console, Re-run last script, Run selection or current block, and more), there's only one Debug selection. Choose Debug, and Spyder opens a dialog that lets you enter command-line arguments, and then simply executes the current source file in Python's debugger, pdb. Obviously, application debugging is not high on Spyder's to-do list.

Because Spyder uses PyQt, you can use Spyder as an extension library for PyQt4 widgets. Spyder's creator explained that some developers have used Spyder as an extension library to embed a Python code editor or console in their PyQt applications. Spyder also provides menu selections that activate the Qt tools: Qt Designer, Qt Linguist, and Qt Demo.

But Spyder is at its best when being used as an interactive console for building and testing scientific and numeric scripts and applications built on NumPy, SciPy, and mathplotlib. I would not choose Spyder for large-scale desktop or Web application development work. But for numerical analytics, I would reach for Spyder first.

Spyder is a Python IDE geared primarily to scientific and mathematical Python developers. It employs the excellent Python numerical libraries of NumPy, SciPy, and mathplotlib.
Spyder is a Python IDE geared primarily to scientific and mathematical Python developers. It employs the excellent Python numerical libraries of NumPy, SciPy, and mathplotlib.
1 2 3 4 5 6 7 8 9 10 11 Page 9
Page 9 of 11