Home

Keeping track of things I want to remember


file() syntax
Python Built-in Functions
File Objects
Efficient arrays of numeric values

os.byteorder will tell you the endianess of the machine you’re on so you can determine whether you should call the array.byteswap() function on your stored data

Python Source Colorizer

Good Python Editors:

SPE – Stani’s Python Editor lots of features, but a bit overwhelming
BBEdit pretty much the only responsive editor on OS X for older machines like mine (g3 iBook)
PyPE lightweight, Scite-based editor. Lacks a lot of features. Couldn’t get script running to work on Win32

Good Python Blogs:

Speno’s Pythonic Avacado
Daily Python-URL
Growlmurrdurr Technical Weblog
Ted Leung on the air
PlanetPython

On another note (*solved below*):

I want to do something like

 try: xls = file(filename,'w') except IOError: // File doesn't exist? try: fw = file(filename,'w') # Create a blank file? fw.close() except: print "File is all jacked up!" raise finally: spr = easyExcel(filename) # use our excel class to open a \ com connection to excel with this file

In order to take care of instances where a file may or may not exist before accessing it. For some reason I get another IOerror on the first IOError exception (when I try to create a blank file by opening it for writing!). Not sure why this is happening, is there an easy way to create a blank file in python that I’m not finding with google or searching the python documentation?

Edit: I got it to work! Here’s the proper code:

 try: xls = file(filename,'r’) xls.close() except IOError, (errno, strerror): try: print “READ: I/O error(%s): %s” % (errno, strerror) fw = file(filename,'w’) fw.close() del(fw) except IOError, (errno, strerror): print “WRITE: I/O error(%s): %s” % (errno, strerror) raise spr = easyExcel(filename)