trace log in error

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Mon Oct 22 14:54:56 CEST 2001


There is a standard library module, traceback, for just this purpose.
>From the manual:

import sys, traceback

def run_user_code(envdir):
    source = raw_input(">>> ")
    try:
        exec source in envdir
    except:
        print "Exception in user code:"
        print '-'*60
        traceback.print_exc(file=sys.stdout)
        print '-'*60

envdir = {}
while 1:
    run_user_code(envdir)

I suggest you read the traceback docs for more understanding.

----- Original Message ----- 
From: "Brian Lee" <senux at senux.com>
To: <python-list at python.org>
Sent: Monday, October 22, 2001 7:13 AM
Subject: trace log in error


> Hi, I'm newbie at Python programming.
> 
> How can I get more detailed error information in
> try.. except sentence?
> 
> Follow code print out what kind of error is occurs
> but I want to read trace log for the error. Is it possible
> to read it? If possible how can I do it?
> 
> try:
>     my_function()
> except:
>     print sys.exc_type, sys.exc_info
> 
> Thank you in advance.
> 
> -- 
> Brian Lee <senux at senux.com>
> 
> You could get a new lease on life 
> 
> -- if only you didn't need the first and last month in advance.
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 





More information about the Python-list mailing list