Posterous theme by Cory Watilo

Filed under: python

Interactive Python Console

One of the great things about Python is exploratory programming, the ability to “dry run” your logic and even design it while working within the interactive interpreter.

The usual Python console is fine for this, although some amenities are missing such as code completion suggestions.  Many more sophisticated options exist as well, such as the excellent IPython, which is basically an interactive console session on steroids.

Don’t get me wrong, IPython is fantastic, however, I’m a bit more GUI in my old age and I like having a variable list available in some corner window of my session.  I’ve always had a dissatisfaction with the GUI Python environments, however.  My former favorite was PyCrust, which is packaged along with the also-excellent wxPython.  It is nothing more than an interactive shell with a couple of those amenities like a variable list.  However, if you don’t do GUI programming much, wxPython is a heavy piece of software to install simply for the shell.

So I’ve tooled along with the interactive interpreter in Pydev, which is itself another piece of software I can heartily recommend.  As an IDE, while I am not entirely satisfied with the cobbled feel of it, Eclipse+Pydev is the best free option for a solid Python development environment that I’ve found.  Again, it’s pretty heavy for just a shell, but since that’s not what it’s primarily used for, you get the shell for free.

Unfortunately, Pydev’s interactive console functionality lags its other features, and it doesn’t have live watches in another pane of the IDE.  That’s ok, though, because there is a great alternative.

Whenever I need to do some Python development in a new environment, I don’t go through all the hassle of setting up Eclipse+Pydev.  Believe me, it takes a while.  There is a fantastic lightweight Python IDE that, as luck would have it, makes a great interactive console environment as well.  That’s PyScripter.  It’s developed in Delphi, meaning it’s fast and the GUI is very functional, while still having a small footprint and packing a lot of power.  If I didn’t like Pydev’s integration with source control and Pylint so much, I’d be using PyScripter (PyScripter also has Pylint integration, but it’s not automated).  While there are a lot of other good free Python IDE’s, and if were earning money with Python software development I might be willing to purchase ActiveState Komodo, PyScripter is a welcome balance of power and ease.

A note on setup.  PyScripter allows different layouts via drag-and-drop.  I put an interactive pane side-by-side with the editor pane by dragging the Python Interpreter tab up from the multi-tabbed pane.  You also want to use the Remote Python Interpreter configuration, which requires an older version of the Rpyc library.  That library is available in the downloads section of the PyScripter website.  Just unzip it and put it in Python’s lib\site-packages directory.  Finally, the wiki portion of the PyScripter website has themes you can download, if you don’t like the available UI looks.  I like the Vista Blue download.