Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

coupling python scripts 1

Status
Not open for further replies.

SanderC

Technical User
Dec 12, 2005
2
NL
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
 
It'd probably be easier to merge them into a single script by importing them.

If you have script1 and script2, then first rename them script1.py and script2.py (otherwise import won't use them).

Second, modify the scripts so that a) all fuctionality that is normally run be default (i.e. not in a function) is in a function, say "main()" and b) change all command line options and arguments to function args.

Finally, write a wrapper script that does somethign like this:
Code:
import script1
import script2

script1.main()
script2.main()

Or, if script1 needs to call script2, then import scrip2 inside script1 and call script2.main() when appropriate in script1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top