Diez B. Roggisch a écrit :
> [EMAIL PROTECTED] schrieb:
> 
>> I have taken the coments and think I have implemented most. My only
> 
> 
> Unfortunately, no.
> 
>> question is how to use the enumerator. Here is what I did, I have tried
>> a couple of things but was unable to figure out how to get the line
>> number.
>>
>> def Xref(filename):
>>     try:
>>         fp = open(filename, "r")
>>     except:
>>         raise "Couldn't read input file \"%s\"" % filename
> 
> 
> You still got that I-catch-all-except in there.
> This will produce subtle bugs when you e.g. misspell a variable name:
> 
> filename = '/tmp/foo'
> try:
>    f = open(fliename, 'r')
> except:
>    raise "can't open filename"
> 
> 
> Please notice the wrong-spelled 'fliename'.
> 
> This OTOH will give you more clues on what really goes wrong:
> 
> 
> 
> filename = '/tmp/foo'
> try:
>    f = open(fliename, 'r')
> except IOError:
>    raise "can't open filename"
> 
> 

And this would be still more informative (and not deprecated...):

filename = '/tmp/foo'
f = open(fliename)

Catching an exception just to raise a less informative one is somewhat 
useless IMHO.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to