Reputation: 11082
I am writing a check.py file which reads a file that maps a python file to an output. That file looks something like this
001.py 233168
002.py 4613732
This means 001.py when ran should print out 233168. What is the best way to capture stdout from 00*.py? Overriding stdout and using execfile? or using a subprocess?
I have never done anything like this before, but it seems like
subprocess.check_output
does exactly what I want, is there a more appropriate way of doing this?
Upvotes: 0
Views: 55
Reputation: 798606
A subprocess. That way the script being executed cannot disrupt the calling script too badly.
Upvotes: 1