subprocess.check_output() doesn't seem to exist (Python 2.6.5)
Question: I've been reading the Python documentation about the subprocess module (see
[here](http://docs.python.org/library/subprocess.html#subprocess-
replacements)) and it talks about a `subprocess.check_output()` command which
seems to be exactly what I need.

However, when I try and use it I get an error that it doesn't exist, and when
I run `dir(subprocess)` it is not listed.

I am running Python 2.6.5, and the code I have used is below:

    
    
    import subprocess
    subprocess.check_output(["ls", "-l", "/dev/null"])
    

Does anyone have any idea why this is happening?


Answer: It was introduced in 2.7 See the
[docs](http://docs.python.org/library/subprocess.html#subprocess.check_output).

Use
[subprocess.Popen](http://docs.python.org/library/subprocess.html#subprocess.Popen)
if you want the output:

    
    
    >>> import subprocess
    >>> output = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE).communicate()[0]
    

