Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
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"
share|improve this question

1 Answer

up vote 2 down vote accepted

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?

share|improve this answer
thanks very much – Barry Taylor Jun 26 at 15:12
i still am having trouble running the actual program "ToBuildOrNot.py MSS_sims" it still runs just ToBuildOrNot – Barry Taylor Jun 26 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 at 12:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.