[python-win32] Exiting an embedded script?
Jesper Hertel
jh@magnus.dk
Tue, 8 May 2001 16:43:57 +0200
Hello Karl,
I am not sure that I completely understand the question, but how about
putting the code in a function and then use raise to quit the function when
needed?
This doesn't work as you said:
... code 1 ...
if condition:
sys.exit()
... code 2 ...
My suggestion is to change it to:
def main():
... code 1 ...
if condition:
raise "exit"
... code 2 ...
try:
main()
except "exit":
# Allow the exit.
pass
I haven't tried it under your circumstances; it is just an idea.
Best regards,
Jesper Hertel
System Developer
Forlaget Magnus A/S
Denmark
jh@magnus.dk
-----Original Message-----
From: Karl Bellve [mailto:Karl.Bellve@umassmed.edu]
Sent: Monday, May 07, 2001 7:35 PM
To: python-win32
Subject: [python-win32] Exiting an embedded script?
I am trying to exit an embedded script before the end of the script. If
I use sys.exit(), the parent application also exits. How can I
prematurely end the python script without ending the parent application.
I am using PyRun_SimpleFile()
I then check the return of that function but if the python script calls
sys.exit(), my program exits before it can do anything about the error.
Any ideas?
--Karl
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32