From: Steven D'Aprano <st...@pearwood.info>
>To: tutor@python.org 
>Sent: Wednesday, August 28, 2013 4:19 AM
>Subject: Re: [Tutor] spss.BasePivotTable
>
>
>On 27/08/13 23:14, Albert-Jan Roskam wrote:
>> Hello,
>>
>> I am trying to create a BasePivot table with three columns: one for the 
>> labels, one for a a category "Before" and one for "After". The following 
>> attempt fails, but what am I doing wrong?
>
>At least two things. Here is the first:
>
>> try:
>    [much code]
>> except spss.SpssError:
>>      print "Error."
>
>You should replace that line with:
>
>print """Python gives you a nice traceback showing you exactly
>what went wrong and where it went wrong, but I'm not going to
>show it to you. Instead, you have to guess, because Screw You.
>"""
>
>It's a little more wordy, but more accurate.

;-) Thank you, I entirely agree. I hate nondescriptive errors myself, too.

>And the second:
>
>> print spss.GetLastErrorMessage()
>
>You're apparently not reading what the last error message is, or if you have 
>read it, you're keeping it a secret from us.
>
>
>What you actually ought to do is preferably get rid of the try...except 
>altogether, at least while debugging. Your aim as a programmer is not to hide 
>errors, but to eliminate them. Hiding them only makes it harder to identify 
>the errors, which is the first step in eliminating them.

 
I was also thinking that there was a bit MUCH code in the try-except. But 
sometimes I keep it all in a try-clause because these lines of code are one 
coherent block.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to