coupling python scripts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sandercaerteling@gmail.com

    coupling python scripts

    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?

    Many thanks!
    Sander

  • Steven D'Aprano

    #2
    Re: coupling python scripts

    On Mon, 19 Dec 2005 02:54:23 -0800, sandercaertelin g wrote:
    [color=blue]
    > 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?[/color]


    Some variation on this should work:




    *** script1.py ***

    def do_stuff():
    print "Hello"

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



    *** script2.py ***

    def do_something_el se():
    print "World"

    if __name__ == "__main__":
    do_something_el se()




    Now write a new script:

    *** master_script.p y ***

    import script1, script2
    script1.do_stuf f()
    script2.do_some thing_else()



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

    *** script.sh ***

    script1.py
    script2.py





    --
    Steven.

    Comment

    Working...