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