Skip to content
Peter M Howard (Contact Options) ::

Peter Howard is Wintermute, mythologist

The site of a film student and geek from Sydney, Australia. Most of the content on the site is arranged under ?bits, which you can navigate by post, month, or category. You may want to subscribe to the Atom feed.

wintermute :: bits

You are currently viewing an individual bits entry. You can navigate individual entries through time, or navigate the archives via the options at the bottom of the page

« Weeping for a Film :: iTunes, Now With Added Freedoms »

Random on Windows

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):

open(photo_path).read()

becomes:

open(photo_path,'rb',0).read()
photos :: recent albums
photos :: random