need exit from 'exec' execution
Fredrik Lundh
fredrik at pythonware.com
Wed Jun 16 17:32:26 EDT 1999
(quick, before the clock strikes midnight, and I'm
switched back to single-process mode!)
Anders Moe <andermoe at online.no> wrote:
> My python-embedded app frequently makes use of 'exec <program-string>'.
> I'd like to create a Tk Button to halt this execution at some point, with the
> option of aborting it. The only command that comes close is the exit state-
> ment, but its to powerful - it exits from the whole app, whereas I only
> wanted a local exit from the exec's program-string. Anyone know how to
> make this kind of local exit ?
are we talking sys.exit here? if so,
import sys
try:
exec "sys.exit()"
except SystemExit:
print "got you"
does what you want.
see the library reference for more info:
http://www.python.org/doc/current/lib/module-sys.html
<F href="http://www.pythonware.com/people/fredrik" />
More information about the Python-list
mailing list