By Rick Grehan | InfoWorld | Published: 16:24, 08 September 2010
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 behaviour 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-colour 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> can be a list, a tuple, a str, or a numpy.array of one or two dimensions. It's important to realise, 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.