-1

Exec, execfile, os.system, subprocess, funtion (if name == main)...

What is the best method, and why, to run multiple python files sequentially as well as possibly multiple times (in a loop) through a single "master" script while also showing status updates via print statements from inside each file on an IDE console?

Retsied
  • 79
  • 8
  • There is no single way. You could use subprocess. Create a queue and a thread that reads the queue and writes to stdout. For each script, map stdout/stderr to a pipe (or pipes) and create a thread that reads them and posts to the queue you created above. – tdelaney Jul 24 '22 at 04:12

1 Answers1

0

It depends on your priorities.

Using the condition if __name__ == "__main__" is beneficial in case your external scripts are not dynamically changing, or, for some reason, you wish to parse all you project files at once at the start of the program.

Other methods are beneficial if you wish to execute your external scripts on demeand or upon dynamic modification of their code.

To sum-up... if __name__ == "__main__" parses all your project scripts at once when the main script run. Other methods start executing your external scripts at the moment the code sequence reachs the execution of each external script.