Skip to content

Reliably Broken

A context manager for files or file-like objects

I usually design my Python programs so that if a program needs to read or write to a file, the functions will take a filename argument that can be either a path string or a file-like object already open for reading / writing.

Read more →

June 7, 2012

Custom template folders with Flask

Someone was asking on Flask’s IRC channel #pocoo about sharing templates across more than one app but allowing each app to override the templates (pretty much what Django’s TEMPLATE_DIRS setting is for). One way of doing this would be to customise the Jinja2 template loader.

Read more →

May 31, 2012

Inspecting your routes in Bottle

Marcel Hellkamp recently added a small feature to Bottle that makes it easy to inspect an application’s routes and determine if a particular route is actually for a mounted sub-application.

Read more →

May 31, 2012

SharpZipLib and Mac redux

I wrote a blog about generating Mac-compatible zip files with SharpZipLib, the conclusion of which was to disable Zip64 compatibility. It was wrong, wrong I tell you.

Read more →

December 1, 2011

SharpZipLib and Mac OS X

TL;DR When creating zip archives with SharpZipLib disable Zip64 format if you care about Mac compatibility.

Read more →

November 18, 2011

Widths & Heights with xlwt + Python

This article about using xlwt to generate Excel in Python reminded me I needed to see exactly how to set column widths (the xlwt documentation doesn't cover it).

Read more →

October 12, 2011

Date variables in InDesign

Interesting InDesign problem: the format for a modification date variable changes per document. (This post describes a problem using Adobe InDesign CS4 but applies just as well to CS5 and CS5 and a half.)

Read more →

September 14, 2011

Free software FTW! Updated filetimes.py

Two years ago (flippin’ heck it seems like only yesterday) I wrote about converting between Unix timestamps and Windows timestamps using Python. In that post I linked to my very simple implementation of a module that provides converting back and forth between the formats.

Read more →

September 10, 2011

XPath bug in old versions of ElementTree

I figured out why my XML parsing code works fine using the pure-Python ElementTree XML parsing module but fails when using the speedy and memory-optimized cElementTree XML parsing module.

Read more →

September 8, 2011

Lion: Spotlight still broken

I’ve installed Mac OS X 10.7 (upgrading from 10.6) and was very interested to see how the new search tokens feature would work in Spotlight. But on my Mac it doesn’t. Here’s the result of a search for files whose name contains the text “david buxton”:

Read more →

August 1, 2011