Re: except clause not catching IndexError

2006-02-23 Thread Sion Arrowsmith
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >You mean to say that "except X,Y:" gives different >results to "except (X,Y):"? > [ ... ] >And here I was thinking that commas make tuples, not >brackets. What is happening here? Similar kind of thing to what's happening here: >>> print "Hello,", "wo

Re: except clause not catching IndexError

2006-02-23 Thread Roy Smith
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > And here I was thinking that commas make tuples, not > brackets. What is happening here? What is happening is that the syntax for forming tuples is one of Python's warts. Sometimes the comma is what makes a tuple: >>> a = 1, 2 >>> type (a) Sometim

Re: except clause not catching IndexError

2006-02-22 Thread Steven D'Aprano
Erwin S. Andreasen wrote: > 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 IndexErro

Re: except clause not catching IndexError

2006-02-22 Thread Derek Schuff
Erwin S. Andreasen wrote: > 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 IndexErro

Re: except clause not catching IndexError

2006-02-22 Thread Scott David Daniels
Derek Schuff wrote: > I have some code like this: > 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": #produ

Re: except clause not catching IndexError

2006-02-22 Thread Ben Cartwright
Derek Schuff wrote: > I have some code like this: > for line in f: > toks = line.split() > try: > if int(toks[2],16) == qaddrs[i]+0x1000 and toks[0] == > "200": #producer > write > prod = int(toks[3], 16) >

Re: except clause not catching IndexError

2006-02-22 Thread Erwin S. Andreasen
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 catchin

except clause not catching IndexError

2006-02-22 Thread Derek Schuff
I'm sorry if this is a FAQ or on an easily-accesible "RTFM" style page, but i couldnt find it. I have some code like this: for line in f: toks = line.split() try: if int(toks[2],16) == qaddrs[i]+0x1000 and toks[0] == "200": #producer wri