Small details can matter (or: a little nifty Python bit)

It's common for Python routines that search for the position ofsomething in a bigger thing (such as characters in a string or listentries in a list) to return -1 when they don't find anything.

I've written Python code for years without really thinking aboutthis. Clearly the routines have to do something when they fail,whether it's raise an exception or return a marker value, and -1 isboth simple and not a valid index into an object.

Only recently (


SMTP IP firewall stats at June 18th, 2005

We maintain a filter list of bad hosts and network areas that can'ttalk to our SMTP port at all; their SMTP packets are silentlydiscarded. The filter list is reinitialized each time the serverreboots, currently once a week. During the week we add various spamsources and high volume sources of other rejections to the filters ona dynamic basis.

As the server does its weekly reboot at 6 AM Sunday morning, right nowis a great time to pull a top-N summary from the kernel's


The problem with CPAN (and other similar systems)

At one level, CPAN is a great thing: people really like having a simpleway of installing Perl packages (and a big archive of them). It's sucha good idea that it's being copied over and over: Python's distutils,Ruby's RubyGems, the R statistic package's CRAN, and no doubt others.

But CPAN and things like it have a problem: they're a package managementsystem. Or, to be more detailed, they're another package


Iterator & Generator Gotchas

Python iterators are objects (or functions, using some magic) thatrepeatedly produce values, one at a time, until they getexhausted. Python introduced this general feature to efficientlysupport things like:

for line in fp.readlines():    ... do something with each line ...

Without iterators, .readlines() would have to read the entire fileinto memory, split it up into lines, and return a huge list; now, thiscode only has one line in memory at any given


AJAX vs Dialups

AJAX is short for 'Asynchronous Javascript And XML', the common termfor the technology behind highly interactive web sites like GoogleMaps and Google Mail. Given that the features AJAX enables (from thelarge to the small) are very appealing to designers, we're pretty muchguaranteed to see more and more use of it on web sites.

But please don't reach for AJAX too fast, because there is such athing as being too interactive.

AJAX's interactivity comes through communication, and communicationtakes


Putting a pleasant Python surprise to use

Although I've been programming in Python for a few years now, it keepssurprising me with little bits and pieces. Here's a neat Python languagefeature that I recently used for the first time (discovered originallythrough Bram Cohen's LiveJournal).

A common programming pattern is 'search for a something to work on, butstop if you don't find anything'. In Python one might write it somethinglike this (taken more or less from DWiki 's source):

found = False

Pitfalls in generating Last-Modified:

Every HTTP reply from a web server can include a Last-Modified: header, which theoretically tells interested parties when the web pagewas last modified. This is really something that works best when theweb server is just sending out static files; when it is generatingdynamic content, like DWiki does, things get interesting.

The major use of Last-Modified: is to decide when a browser already hasa current copy of the web page and doesn't need to fetch it again. Thus,with dynamic pages


Why a Blog?

Honesty compels me to admit that part of why I am trying blogging isthat I coded a bunch of blog features into DWiki , my wiki-thing, and Iwould feel kind of stupid if they never got used. (The blogdir codehas a clear usage case, but the blog code does not quite so much.)

But that's not all of it. Web pages cry out for a linking structure,an organization, a taxonomy, just like we are supposed to sensiblyorganize directories on our computers


Making a Python mountain out of a molehill

DWiki is the software that runs CSpace , including this blog . It'swound up much bigger than I expected and wanted it to be. This is sortof the story of how (or why) that happened.

DWiki started out with a simple goal: serve up (revision controlled)wiki-text documentation as HTML pages. It didn't have to edit thepages; we'd do that in a real editor in a real environment. The coreprogram model was simple: pages would be generated


I find myself quite irritated with CSS lately, because I have beentrying to be a good modern web-boy and style this place with CSS.

The problem with CSS is what it leaves out. Take a very simple example:this blog . Like many blogs, I want a two-column layout: blogentries on the left, a small sidebar about the blog on the right.

No problem in CSS: use two

s, set a width: or a min-width:, and