Windows/DOS: double clicking a .py file

Bjorn Pettersen BPettersen at NAREX.com
Mon Sep 9 17:52:08 EDT 2002


> From: Just [mailto:just at xs4all.nl] 
> 
> Sorry if this is a Windows FAQ, I'm a newbie to Windows, but not to 
> Python.
> 
> If I double-click a Python script (or use the start command 
> in the dos 
> prompt) a new dos prompt window is opened and my program is run. The 
> window goes away when the program is done. However, the window _also_ 
> goes away when the program raises an exception, making it virtually 
> impossible to actually _see_ the exception... Is there a way 
> to keep the 
> dos prompt window in this case?

Try something like the following... We've had much success with
automatically emailing the traceback back to the developer using the
cgitb module -- you can never trust users to give you good error reports
<wink> besides the cgitb module provides much more context than the
standard exceptions... Let me know if you'd like the code...

try:
    your code here
except:
    import msvcrt, traceback
    traceback.print_exc()
    print 'Hit a key to exit'
    while not msvcrt.kbhit():
        pass
    
-- bjorn




More information about the Python-list mailing list