If you're on Windows (or a pedant;-), open(filename)
is the wrong way to open a binary file and might mess things up -- use open(filename, 'rb')
. Apart from that, assuming of course that you continue with a urllib2.urlopen(request)
which you've omitted, that your import
s are correct, and that filename
and url
are properly set previously, then your code seems legit.
Alex Martelli
2010-07-17 03:50:58