Peter M Howard ::

Random on Windows

15May2007 [webprog]
[tweet this]

In which I am baffled by the mystery that is Windows, and once more wooed by the ease with which one can make Python work, even there

Have been trying to get this site running on my Windows box at work, which has been an interesting experience… Some of the things I’d done to set it up properly were particularly helpful - using SVN and using separate settings modules both make it really easy to tweak things without breaking the site in its other instances.

Most things just worked - going from *nix to Windows is pretty easy, it’s going the other way that usually hurts… So far only ran into one weird bit, with my randoms app. The random image loading just wasn’t working. I loaded up the python shell and tried there; still no good, using the bare minimum of python code. But after trying open(photo_path).read() on a few different files, I noticed that it was returning very similar strings, and that they were a lot shorter than they should have been… Loaded up the python help (love being able to write p = open(photo_path) and help(p) to find out everything I can do!) and discovered a buffer setting. Sure enough, had to explicitly tell it not to buffer the file, but just read it all in one hit. No idea what the environmental difference is, but that’s solved my problems, and I’ve just tested on my Linux box at home and it works properly here too.

One little change then (which I’ve made to the original post also):