Snippets about subprocesses.

calling an external command

from subprocess import call
call(["ls", "-l"])

subprocess input, output and returncode

from subprocess import Popen, PIPE

p = Popen(["ls", "-l"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
std_input = "/"
out, err = p.communicate(std_input)
returncode = p.returncode

use string to call subprocess instead of list

from subprocess import call
import shlex

command = "ls -l"