Re: exception problem

Discussion in 'Python' started by MRAB, Jun 26, 2012.

  1. MRAB

    MRAB Guest

    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
    > <> 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!
     
    MRAB, Jun 26, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jeff
    Replies:
    0
    Views:
    1,535
  2. jeff
    Replies:
    3
    Views:
    1,691
    Scott
    Jun 26, 2003
  3. Kerri
    Replies:
    2
    Views:
    13,034
    Kevin Spencer
    Oct 27, 2003
  4. Ola
    Replies:
    0
    Views:
    534
  5. Selen
    Replies:
    0
    Views:
    2,688
    Selen
    May 28, 2004
Loading...

Share This Page