0
import os
import pdb

os.system("ToBuildOrNot.py MSS_sims")

for output in os.system:
     if ToBuildOrNot is True:
         print "The MSS_sims Needs To rebuilt"

     elif ToBuildOrNot is False:
         print "The MSS_sism does NOT Need to be Rebuilt"

     else:
         print "error"
Jørgen R
  • 10,568
  • 7
  • 42
  • 59

1 Answers1

2

Don't invoke a Python script from a Python script by using system, which spawns a whole other interpreter. Just import it. Like this:

import ToBuildOrNot
needsBuild = ToBuildOrNot.run() # or whatever you call your top-level function

Since ToBuildOrNot.py is a script now, make sure the "main" function is protected so it doesn't execute automatically on import. Most people do it this way in Python: What does if __name__ == "__main__": do?

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • i still am having trouble running the actual program "ToBuildOrNot.py MSS_sims" it still runs just ToBuildOrNot – Barry Taylor Jun 26 '13 at 15:31
  • You need to define a function like `def run(filename)` (in my example), and then call it with "MSS_sims" to pass in the filename. – John Zwinck Jun 27 '13 at 12:52