subprocess, capturing shell command output

#!/usr/bin/env python

import subprocess

p = subprocess.Popen( 'ls', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
lines = []

while True:
    line = p.stdout.readline()
    if line == ” and p.poll() != None:
        break
    lines.append(line)

print( lines)