Derek Schuff <[EMAIL PROTECTED]> writes: > I have some code like this:
[...] > except IndexError: #happens if theres a partial line at the > end of file > print "indexerror" > break > > However, when I run it, it seems that I'm not catching the IndexError: > Traceback (most recent call last): > File "/home/dschuff/bin/speeds.py", line 202, in ? > if int(toks[2],16) == qaddrs[i]+0x1000 and toks[0] == "200": #producer > write > IndexError: list index out of range Did you by any chance do something like: except ValueError, IndexError: at some point earlier in this function? That, when catching ValueError assigns the resulting exception to IndexError (and so the following except IndexError: wouldn't work as IndexError is no longer what you think it is). The correct syntax for catching multiple exceptions is: except (ValueError, IndexError), targetVariable: You could verify this by doing a print repr(IndexError) before your line 202, to see that it really is the IndexError builtin. -- =============================================================== <[EMAIL PROTECTED]> London, E14 <URL:http://www.andreasen.org/> <*> =============================================================== -- http://mail.python.org/mailman/listinfo/python-list