Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

win32: Leaving Dos Box open

0 views
Skip to first unread message

Thomas Guettler

unread,
Jul 9, 2002, 9:25:12 AM7/9/02
to
Hi!

How can the dos box be left open when I run foo.py from
the windows explorer and there is a syntax error?

thomas

Duncan Booth

unread,
Jul 9, 2002, 10:01:54 AM7/9/02
to
Thomas Guettler <zopes...@thomas-guettler.de> wrote in
news:3D2AE438...@thomas-guettler.de:

Try something like this:
---- error.py ---
import sys
def excepthook(t,v,tr, old=sys.excepthook):
old(t,v,tr)
raw_input("Press return to exit")
sys.excepthook = excepthook

x = 3/0
print "Done"
---- end of error.py ---

Copy the top 5 lines somewhere near the top of your own script.

Alternatively wrap a try:except: handler around the main loop of your
script. I sometimes use code like this:

if __name__ == '__main__':
try:
# main program code goes here...
main()
except:
# In case of emergency, lets debug!
import pdb, sys, traceback
sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
traceback.print_last()
pdb.pm()

Which not only keeps the window open, but throws you into a debugger for
good measure.

--
Duncan Booth dun...@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

Bo M. Maryniuck

unread,
Jul 9, 2002, 9:30:29 AM7/9/02
to

Way No.1
------[COOL.BAT]----------
C:\PYTHON\PYTHON.EXE your_cool_program.py
pause
---------------------------

Way No.2
a) Start->Run->Command
b) C:\PYTHON\PYTHON.EXE your_cool_program.py


Way No.3 (best of all)
a) Insert boot CD with Linux
b) Reboot...

--
Sincerely yours, Bogdan M. Maryniuck

"A word to the wise: a credentials dicksize war is usually a bad idea on the
net."
(David Parsons in c.o.l.development.system, about coding in C.)

Gerhard Häring

unread,
Jul 9, 2002, 9:30:22 AM7/9/02
to
* Thomas Guettler <zopes...@thomas-guettler.de> [2002-07-09 15:25 +0200]:

> How can the dos box be left open when I run foo.py from the windows
> explorer and there is a syntax error?

I don't think it's worth bothering with that.

Just execute your script on a commandline or in an IDE like IDLE or
PythonWin.

Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))


0 new messages