Great War Digital Archive

[posted by Gavin Robinson, 5:39 pm, 3 March 2008]

Today the Great War Archive opened for submissions. This is a very big and very innovative project started by Oxford University to collect digital facsimiles of documents, photographs, recordings, and artefacts relating to the First World War (it seems to be primarily about the UK but they haven’t explicitly mentioned any geographical limits) from private individuals. This means that lots of family collections which were previously unknown and inaccessible will be made available to the public (and since the terms for contributors state that material will only be used for educational non-commercial purposes I’d hope that access is going to be free). Anyone can contribute material by uploading it through the project’s website, and there will also be special events where people who don’t have the IT skills or equipment can bring items along to have them digitized.

This is a really exciting project, and I hope it all goes well. We’ll be contributing the Wenham letters that I’ve been working on (although I’m still planning to put TEI transcripts on my own site eventually, along with all the same kind of record linkage that I’ve done with Sandall’s history), so I’ll soon be able to report on how easy it is to upload stuff and what kind of metadata they collect.

If everything goes to plan the archive will be open to viewers from 11th November 2008.

Top Tips for the Python Programmer

[posted by Gavin Robinson, 12:45 pm, 3 March 2008]

Last week I learnt about using exceptions, which turned out to be the solution to a problem that I’ve mentioned before: if you try to do anything with a variable that hasn’t been initialized, Python throws an exception. In many ways this is good, because trying to do things with non-existent variables can otherwise be a source of hard to find bugs. However, I found it quite annoying when I got exceptions just for checking for a variable and only trying to do things with it inside an if block if it exists. Even the seemingly innocuous statement “if x” will bring a program to a halt if x doesn’t exist.

The way around this is to handle the exception when it occurs, so that the program keeps running but you know that the variable doesn’t exist. For example:

try:
    x
except NameError:
    #x doesn't exist
else:
    #x does exist

This code tries to reference x. If x doesn’t exist, an exception occurs and the code after except is executed (but only if the type of exception thrown matches what’s specified between except and the colon). If x does exist the code after else is executed instead. This is a bit long winded compared to “if x” but it’s better than nothing. Also be aware that different kinds of variables throw different kinds of exceptions when they don’t exist.

  • NameError – any single instance of a built in type or custom object, or a sequence where the sequence itself doesn’t exist, eg x
  • IndexError – numerical index of a sequence where the sequence exists but the specified element doesn’t, eg x[5]
  • KeyError – index of a map where the map exists but an element with that index doesn’t, eg x['y']
  • AttributeError – attribute of an object where the object exists but the specified attribute doesn’t eg x.y (often occurs with objects representing XML elements as it can be difficult to predict what child elements they contain)
Newer posts