import subprocess
logfile = open('/dev/log', 'w')
output, error = subprocess.Popen(['ls'], stdout=logfile, stderr=subprocess.PIPE
    ).communicate()
In Python, what is the best way to execute a local Linux command stored in a string?