Difference Between stdout=subprocess.PIPE and stdout=PIPE
So The title pretty much explains my question. What is the difference between stdout=subprocess.PIPE and stdout=PIPE? Both come from the subprocess module, but why would you use one over the other? How do you use stdout=PIPE? Ie capture the output? Or print it to the screen? I only know how to redirect it with subprocess.PIPE.
eg
import subprocess
from subprocess import PIPE
p = subprocess.Popen(['samtools', 'view', 'bamfile.bam'], stdout=PIPE)
from subprocess import PIPE
makes subprocess.PIPE
available under the alternative name PIPE
; it is equivalent to:
PIPE = subprocess.PIPE
Therefore, it does not matter which version you choose. subprocess.PIPE
makes it clear where the variable is coming from, but is slightly longer.