[Tutor] executing script from script
alan.gauld at btinternet.com
Mon Nov 6 18:29:11 CET 2006
"Eli Brosh" <ebrosh at nana.co.il> wrote
> I wish that my Python program will not be stored on a single file.
> how can I call one python script from another ?
As Kent says normally you don't call one script from another,
instead you write a set of functions (or classes) that you put in
one or more modules. You then import those modules into
your top level script (the one you actually execute) and call the
functions in the modules.
You can read more about this in my Modules and Functions
topic in my tutorial.
If you really do want to call a Python script you do it the same
way as you would call any other executable program from
inside a script: using the subprocess module. This is described
in my Operating System topic, in the "Other mechanisms for
external program access" subsection.
Author of the Learn to Program web site
More information about the Tutor