Keeping console window open

Scott David Daniels Scott.Daniels at Acm.Org
Sun Jun 7 15:26:00 CEST 2009

Tomasz Zieliński wrote:
> On 7 Cze, 14:49, Fencer <no.i.d... at> wrote:
>> My question is how can I trap
>> errors encountered by the interpreter (if that is the right way to put
>> it) in order to keep the console window open so one has a chance to see
>> the error message?
> Interpreter errors are same beasts as exceptions,
> so you can try:...except: them.

To be a trifle more explicit, turn:

       if __name__ == '__main__':

       if __name__ == '__main__':
          except Exception, why:
              print 'Failed:', why
              import sys, traceback
          raw_input('Leaving: ')

Note that building your script like this also allows you to
open the interpretter, and type:
     import mymodule
in order to examine how it runs.

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list