DPM
DPM

Reputation: 935

How to create a queue of python scripts to run one after the other

I would like to know if it is possible to select python scripts and have them run one after the other. So the first python script runs and gives me the desired result, after this I want another script to run. Example:

Imagine we have 3 scripts: code1.py, code2.py and code3.py. Now I would like to create something that would allow me to run first code1.py, then after that is done run code2.py and finally code3.py.

Is this possible?

P.S- Apologies for not displaying an attempt, I don't have sufficient coding knowledge to be able to do an attempt.

Upvotes: 0

Views: 1618

Answers (2)

Manu N.
Manu N.

Reputation: 26

IF your scripts are not functions, you can just import them one after an other (if they are in the same folder). Like that they will run on after an other

import code1
import code2
import code3
# And so on...

Upvotes: 1

Ted Brownlow
Ted Brownlow

Reputation: 1117

It sounds like using functions from another file is what you're after

from code1 import do_first_thing
from code2 import do_second_thing
from code3 import do_third_thing

def main():
  do_first_thing()
  do_second_thing()
  do_third_thing()

Upvotes: 2

Related Questions