0

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?

1 Answer 1

1

A subprocess. That way the script being executed cannot disrupt the calling script too badly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.