simple question...

David Bolen db3l at fitlinxx.com
Fri Jun 23 22:18:00 EDT 2000


chibaA at TinterlogD.Tcom writes:

> At the end of a script A, I would like to initiate script B.  I don't
> want to run script B as a function in A; rather, I want to quit A, and
> start script B.  Is this possible?

Try the os.exec* functions in the os module.  It sounds pretty much
like what you want to do.  The exec* functions replace the current
running executable with another executable - only one process slot is
involved, and the original executing code does not exist following the
exec call.

Note however that since you'll be replacing your current process, you
actually need to exec python giving it the new script as an argument,
rather than just directly-exec()ing the script.

You can use sys.executable to determine the python that is executing
the current script and just exec() that with an argument of the new
script.

You don't note your platform, but I believe this is documented for
both Windows and Unix.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list