A way to wait Python event

Diez B. Roggisch deetsNOSPAM at web.de
Tue Nov 30 17:50:09 EST 2004


> I tried to launch "python.exe test.py" in another program. After the
> launch the console was showed and exited on Windows. I want the
> console stay there. Is there a Python statement to wait an event loop
> like Tcl's "after forever"?

I'm a happy linux user who is always amazed by such things when using
windows. So the first thing I do on a windows-box is to install cygwin, and
then execute commands from a proper shell.

Apart from that, I believe what you expirience has nothing to do with python
- windows just kills the command-window if your app exits. And thats well
after python is actually in command.

So maybe you can do somthing like this:

if __name__ == "__main__":
    try:
        ... # do something
    except:
        print sys.exc_info()[1]
        while True:
             time.sleep(0.2)

That should stop the interpreter in case of an exception. Unindenting the
last while will wait in every case, so you can inspect the output
nonetheless.

Apart from that, there might be some hidden "keep this damn window open
after the executed progam terminated"-checkbox. Happy hunting.
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list