Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24488 > unrolled thread

Re: exception problem

Started byMRAB <python@mrabarnett.plus.com>
First post2012-06-26 23:30 +0100
Last post2012-06-26 23:30 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: exception problem MRAB <python@mrabarnett.plus.com> - 2012-06-26 23:30 +0100

#24488 — Re: exception problem

FromMRAB <python@mrabarnett.plus.com>
Date2012-06-26 23:30 +0100
SubjectRe: exception problem
Message-ID<mailman.1532.1340749856.4697.python-list@python.org>
On 26/06/2012 22:36, Chris Angelico wrote:
> (You posted privately to me again; I hope you don't mind my responding
> on-list as this appears to have been merely oversight.)
>
> On Wed, Jun 27, 2012 at 5:25 AM, Charles Hixson
> <charleshixsn@earthlink.net> wrote:
>> Only thing is, this whole mess started when I was trying to trace down and
>> expected error.  (Which turned out to be "self.chunkLine(..." where self
>> wasn't defined.)  It was running without ANY error being displayed.  Though
>> as I look an outer loop is inclosed in a try:except:finally:  It still has
>> an unlabelled except, because I don't remember what exception is thrown when
>> a file reads an unintelligible character  (i.e., it isn't really a utf-8
>> file).  Currently I've fixed all the files so that they're either utf-8 or
>> just ASCII, so currently it isn't getting triggered, but it's still there.
>>  So that's probably the explanation.  I think I'll fix that now.  (I can, I
>> guess, assume that any exception will be caught by except BasicException:)
>
> That's the problem, your blanket try/except. Don't do it! It blinds
> you. Same goes for catching Exception or BaseException. Catch what you
> really need to catch, and reserve catch-all statements for special
> cases where you don't have access to the console.
>
If you can't remember what exception is raised, just try raising it 
deliberately.

Python _can_ be used interactively, after all. Even a short script to
test it won't take you very long!

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web