Saturday, December 7, 2002


If you dig deep into one of Peter Norvig's python pages. He mentions what he has in his .python startup file. In particular, he adds a results history and auto-completion. Example:

>>> import Foundation
>>> Foundation.NSAr<tab><tab>
Foundation.NSArchiver Foundation.NSArgumentsWrongScriptError
Foundation.NSArgumentDomain Foundation.NSArray Foundation.NSArgumentEvaluationScriptError
>>> Foundation.NSAr

I grabbed his code and packaged it for easier distribution. I also modified it slightly such that the output is compatible with doctest (i.e. the output is unchanged from normal Python). I left the original fancy red prompt with history indication in the code, but commented out.

Grab the tarball and drop the resulting directory in ~/ (your home directory). Once done, add...

setenv PYTHONSTARTUP ~/.python/init.py

... to .cshrc, .login, or whatever shell script initializer you use (i.e. set the PYTHONSTARTUP environment variable).

To test: Create a new shell window and hit tab twice. Python should ask if you want to show all X bazillion possible completions.

You will need readline support, which doesn't come with the OS X build of python, but does with just about every other build of python on the planet. It is easy to add to the OS X distributed version of python, though.

The history can be accessed through the variable h. It is just an array that contains all previous return values from expressions executed [that did not return None]. Trivial, potentially handy.

As always, changes, fixes and improvements are always welcome. Maybe this thing will grow into the hairy beast that is [was] my Emacs initialization environment.
2:58:37 PM  pontificate    


I have four goldfish, a sunfish [generic farm pond fish] and an algae eater [the "horse fish" as my son calls it] in a good sized tank in my office. The goldfish should be called pigfish-- they eat anything that falls into the tank. Or try to. Unfortunately, this includes the algae tablets for the algae eater. If anyone has any ideas as to how I might keep the damned goldfish from eating the algae eater's food, I would love to hear it.

At the right time of the day, the sun comes in through the window and hits the fish tank fairly directly. Not enough to boil the fish, but enough to grow algae at a pretty astounding rate. Not fast enough to keep the algae eater fed, but the algae growth was the original reason for the addition of a plechy.

It is amusing to watch all of the goldfish dive frantically for the bottom of the fish tank any time a bird flies by such that its shadow passes by the tank. Some instincts run strong. The sunfish ignores it as it is largely a bottom fish anyway. The algae eater obviously believes it is completely invisible by simply staying stuck to the glass in the corner.

In other news, my son and wife are both suffering from an evil 6-hour illness that effectively empties the sufferer's digestive tract as fast as possible. Unpleasnt.

However, I did manage to convince my son that barfing directly into the toilet is a far more pleasant experience than barfing on the floor, dad, the dog, in the bed, on himself, or onto/into whatever else happens to be in range at the moment.

Not that it is a huge improvement. It seems that little kids barf with hair trigger sensitivity and speed. But, at the list, if he is moving forward, it a far cry better than the typical 'look up at the nearest adult while spewing down your front'.

Disgusted yet? I am. Deeply. Can't tell if I'm getting the disease or if this feeling of disgust is just from dealing with it in others...
1:47:02 PM  pontificate