coupling python scripts

Steven D'Aprano steve at
Mon Dec 19 12:55:05 CET 2005

On Mon, 19 Dec 2005 02:54:23 -0800, sandercaerteling wrote:

> Hi There!
> I created a few python scripts and everything is working fine. But to
> make it easier to run the procedure i want to couple these scripts in
> one big script. Is there a possibility to do this, can I for example
> make a script dat 'calls' the other script in the right order?

Some variation on this should work:

*** ***

def do_stuff():
    print "Hello"

if __name__ == "__main__":
    # execute this when being called as a script

*** ***

def do_something_else():
    print "World"

if __name__ == "__main__":

Now write a new script:

*** ***

import script1, script2

Or even simpler, since and are callable from the
command line, just create a shell script and let your shell handle it:

*** ***


More information about the Python-list mailing list