Traceback disapears before I can read it!
Greg Fortune
lists at gregfortune.com
Sun May 11 18:27:27 EDT 2003
I've started included a piece of code similar to the following at the
bottom all my main scripts that will need to run on Windows...
if(__name__ == '__main__'):
try:
main_func()
except Exception, e:
import traceback
retval = -1
print 'An error has occurred.\n\n'
traceback.print_exc()
print '\n\n'
temp = raw_input('Press [Enter] to exit.')
This way, even if a user of the program somehow causes a problem, they can
include the traceback in an e-mail or call you and read it off... Yes,
hopefully they never see one of those messages, but it has saved me a trip
into a client's office before...
Greg Fortune
Fortune Solutions
Edward K. Ream wrote:
>> Of course, I still need to see a traceback to debug my programs. If I
>> invoke my wxPython app using PYTHON.EXE, I can get a stdout window,
>> which prints the traceback and any print statements that I might
>> include in my program. So far, so good. However, if an error
>> actually occurs the stdout window closes immediately after printing
>> the traceback.
>
> Invoke Python with the -i argument so that Python stays in interactive
> mode
> after your script exits. For example, on XP, in the Settings:Folder
> option dialog, set the open option for .py files to:
>
> C:\PYTHON22\python.exe -i "%1" %*
>
> Edward
> --------------------------------------------------------------------
> Edward K. Ream email: edreamleo at charter.net
> Leo: Literate Editor with Outlines
> Leo: http://webpages.charter.net/edreamleo/front.html
> --------------------------------------------------------------------
More information about the Python-list
mailing list