Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's a crossword game like Scrabble, but played with hexagonal tiles. http://www.hexalex.com

NOTE: I'm afraid my situation has changed and I haven't written any python in quite some time. It would be best to consider these programs unmaintained. If anybody is interested in taking over maintainence of something, feel free to contact me about it.

Apparently somebody found my Python hacks interesting. They got written up on O'Reilly's onlamp.com website.

I also got one of my Python recipes in O'Reilly's Python Cookbook! It's a cute hack called Quicksort in Three Lines. I guess my legacy will be cute hacks...

gracePlot.py [UNMAINTAINED]
(See Mike McKerns' pygrace and pyIDL packages for something more up-to-date.)

This module provides interactive 2-D plotting capabilities via the Grace package. Why do we need yet another plotting package for Python? Simple. None of the packages out there (that I've tried) currently offer all of the following desirable properties:

  • Designed for use at the interactive prompt
  • Provide UI access to plot properties and allow changes on-the-fly
  • Tight integration with Numeric Python

A typical gracePlot session goes something like this:

>>> from gracePlot import gracePlot
>>> p = gracePlot() # A grace session opens
>>> p.plot( [1,2,3,4,5], [10, 4, 2, 4, 10], [1, 0.7, 0.5, 1, 2],
...         symbols=1 )  # A plot with errorbars & symbols
>>> p.title('Funding: Ministry of Silly Walks')
>>> p.ylabel('Funding (Pounds\S10\N)')
>>> p.multi(2,1)  # Multiple plots: 2 rows, 1 column
>>> p.xlimit(0, 6)  # Set limits of x-axis
>>> p.focus(1,0)  # Set current graph to row 1, column 0
>>> p.histoPlot( [7, 15, 18, 20, 21], x_min=1, 
...              dy=[2, 3.5, 4.6, 7.2, 8.8]) # A histogram w/errorbars
>>> p.xlabel('Silliness Index')
>>> p.ylabel('Applications/yr')
>>> p.xlimit(0, 6)  # Set limits of x-axis

and you end up with this:

You'll need Grace v5.1.4, grace_np.py (local copy) by Michael Haggerty, and Numerical Python. I'm pretty sure gracePlot should work with Python 1.5.2 and up, though I've only tested with Python 2.1.1 and Numpy 20.1.0.

deep_reload.py [UNMAINTAINED]
This is a drop-in replacement for the reload() builtin command that causes recursive reloads. It is very handy for interactive development when you want to reload your whole project at once rather than one file at a time. For Python 1.5.2 and above.

LazyPython.py [UNMAINTAINED]
A neat hack that works with Python version 2.1 or greater. It adds shell escapes, auto-quoting, and auto-parenthesizing to the interactive Python prompt. See the docstring for details.

Fernando PÈrez liked this idea a lot and took it much further, so if you'd prefer something more powerful (but also a bit more complicated) you might want to check out IPython.

ultraTB.py v0.3 [UNMAINTAINED]
Two classes to spice up your tracebacks! ColorTB colorizes the standard Python tracebacks to make them easier to parse visually. VerboseTB is a port of Ka-Ping Yee's cgitb.py (soon to be in the standard library) that writes colored text to the terminal instead of HTML. Here's a screenshot of ColorTB in action. Here's one for VerboseTB.

Note: Thanks to William McVey for submitting a patch for good xterm support.

pythonstartup.py [UNMAINTAINED]
This is my pythonstartup file for interactive Python sessions. It does some nifty things like colorize the prompts, enable command completion, set pprint as the display hook for more readable lists and dicts, and define a bunch of utility functions. Most of these come from Robin Friedrich's interactive.py, which I found on Janko Hauser's website, but many of the functions have been extended. I have also added an "edit" function that takes a filename, function, class, method, or module and opens the correct file on the correct line for editing.

This file takes advantage of deep_reload, ultraTB, and LazyPython if they're present but doesn't require them. It will work on Python 1.5.2 or above.

Note: Prompt/traceback colorization now work. Thanks to Stephan Fiedler for the fix!

versionChk.py [UNMAINTAINED]
Since everybody's in such a tizzy about incompatible changes in Python I've written a little function that checks the version of the interpreter and ensures that it's between a minimum and maximum version that you specify. By default it issues a warning for versions after the maximum and an exception for versions before the minimum, but this can be customized. I've tested this on Python versions 1.4 through 2.1.1.

  • Share/Bookmark

Like my work? Check out HexaLex, my game for iPhone & iPod Touch. It's a crossword game like Scrabble, but played with hexagonal tiles. http://www.hexalex.com