Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: exception problem

Reply
Thread Tools

Re: exception problem

 
 
Charles Hixson
Guest
Posts: n/a
 
      06-25-2012
On 06/24/2012 03:43 PM, Charles Hixson wrote:
> On 06/24/2012 03:36 PM, Chris Angelico wrote:
>> On Mon, Jun 25, 2012 at 8:26 AM, Charles Hixson
>> <> wrote:
>>> The code:
>>> finally:
>>> print ("at finally")
>>> print ("chunks =")
>>> produces this result:
>>> path 3...

>> Can you state more clearly the problem, please? I'm seeing output that
>> can't have come from the code posted (for instance, immediately after
>> the "at finally", I'm expecting to see the "chunks =" line), and I'm
>> not seeing any exception information, so I can't even hazard a guess
>> as to what's throwing the exception.
>>
>> Presumably these are two methods in the same class, since you're
>> calling it as "self.chunkLine", but beyond that, it's hard to know.
>> Take off the try/except and let your exception go to console, that's
>> usually the easiest thing to deal with.
>>
>> Chris Angelico

> Sorry, but it *DID* come from the code posted. Which is why I was so
> confused. I finally tracked it down to "self was not defined" by
> altering the except section to read:
> except BaseException as ex:
> print ("caught exception")
> print (ex)
> finally:
> print ("at finally")
>

The documentation section covering the except statement could stand to
be a *LOT* clearer. I read the sections on the except statement and
exception handlers several times and couldn't figure out was the "as"
argument of the except statement was for. "Target" doesn't communicate
much to me. The one I finally used as indicated above was modified from
some code that I found through Google. I still don't really know what
"as" means, except that if you use it, and you print out the "target",
you'll get some kind of informative message. (The one that I got said
"self was not defined" .. that's a paraphrase. I can't remember the
precise wording.) And that interpretation is based on what the result
was, not on anything said in the documentation.

IIRC, the Python2 documentation used code examples to indicate what was
the right way to write an exception handler. I realize that Python3 is
much different, but that approach was a very good one.
>



--
Charles Hixson

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Throw Exception Vs Throw New Exception Kerri ASP .Net 2 10-27-2003 02:13 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 3 06-26-2003 01:02 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 0 06-24-2003 12:46 PM



Advertisments