Message from discussion exception problem
Received: by 10.68.228.227 with SMTP id sl3mr280651pbc.5.1340843782138;
Wed, 27 Jun 2012 17:36:22 -0700 (PDT)
From: alex23 <wuwe...@gmail.com>
Subject: Re: exception problem
Date: Wed, 27 Jun 2012 17:36:21 -0700 (PDT)
References: <4FE79433.firstname.lastname@example.org> <4FE7982C.email@example.com>
X-Trace: posting.google.com 1340843782 22031 127.0.0.1 (28 Jun 2012 00:36:22 GMT)
NNTP-Posting-Date: Thu, 28 Jun 2012 00:36:22 +0000 (UTC)
Injection-Info: wt8g2000pbb.googlegroups.com; posting-host=184.108.40.206; posting-account=rYyWJQoAAACVJO77HvcyJfa3TnGYCqK_
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11
(KHTML, like Gecko) Chrome/20.0.1132.43 Safari/536.11,gzip(gfe)
Content-Type: text/plain; charset=ISO-8859-1
On Jun 28, 10:13=A0am, Charles Hixson <charleshi...@earthlink.net>
> On 06/25/2012 12:48 AM, Steven D'Aprano wrote:
> > "Catch any exception" is almost certainly the wrong thing to do, almost
> > always.
> This time it was the right thing, as I suspected that *SOME* exception
> was being thrown, but had no idea what one. =A0The problem was I didn't
> know how to print the result when I caught the exception.
I think you're still missing the point. If you _didn't_ have a bare
try/except, the exception _would have been raised_ and the exception
You _don't_ need an exception handler for exceptions to occur, they
just occur. You _only_ need a handler when you want to, y'know, handle
> This has
> since been cleared up, but first I found it on Google, and then I was
> told about it on the list. =A0The documentation left me totally ... well,
> not uninformed, but confused. =A0As I said it turned out to be a method
> call on an uninitialized variable, as I found out once I figured out how
> to list the result of catching the exception. =A0Which is what I expected
> the documentation to show me how to do.
The documentation doesn't expect you to write code to block error
reporting. If you had just removed the try/except, you would have seen
the problem right away.
> What really annoys me is the way the documentation has worsened since
> python 2.5, but if you know what it is trying to tell you, then I guess
> you aren't bothered by undefined terms and lack of examples. =A0I went
> away from programming in Python for a couple of years though, and I
> guess I missed the transition, or something.
Can I suggest re-looking at the tutorial for errors & exceptions? I
really think you're making this a lot more difficult for yourself than
it needs to be.