I want to run the following bash command in Python 3:
ls -l
I know that I can do the following:
from subprocess import call
Read about Popen. the set you asked for you get with
import subprocess
proc = subprocess.Popen(['ls','-l'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
myset=set(proc.stdout)
or do something like
for x in proc.stdout : print x
and the same for stderr
you can examine the state of the process with
proc.poll()
or wait for it to terminate with
proc.wait()
also read
read subprocess stdout line by line