Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
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)
Path: l9ni27628pbj.0!nntp.google.com!news1.google.com!postnews.google.com!wt8g2000pbb.googlegroups.com!not-for-mail
From: alex23 <wuwe...@gmail.com>
Newsgroups: comp.lang.python
Subject: Re: exception problem
Date: Wed, 27 Jun 2012 17:36:21 -0700 (PDT)
Organization: http://groups.google.com
Lines: 41
Message-ID: <962dcbfa-4746-4764-937f-2f101aa74141@wt8g2000pbb.googlegroups.com>
References: <4FE79433.8020704@earthlink.net> <4FE7982C.5020708@mrabarnett.plus.com>
 <mailman.1466.1340579780.4697.python-list@python.org> <4fe817d3$0$29866$c3e8da3$5496439d@news.astraweb.com>
 <mailman.1578.1340842369.4697.python-list@python.org>
NNTP-Posting-Host: 132.234.83.56
Mime-Version: 1.0
X-Trace: posting.google.com 1340843782 22031 127.0.0.1 (28 Jun 2012 00:36:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 28 Jun 2012 00:36:22 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: wt8g2000pbb.googlegroups.com; posting-host=132.234.83.56; posting-account=rYyWJQoAAACVJO77HvcyJfa3TnGYCqK_
User-Agent: G2/1.0
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
Content-Transfer-Encoding: quoted-printable

On Jun 28, 10:13=A0am, Charles Hixson <charleshi...@earthlink.net>
wrote:
> 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
displayed.

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
them.

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

http://docs.python.org/tutorial/errors.html