Python - I'm trying to get the output of pwd and instead i get the exit status
Question: I'm trying to get the output of `pwd`:

    
    
    #!python
    import os
    pwd = os.system("pwd")
    print (pwd)
    

it prints 0 which is the successful exit status instead the path. How can i
get the path instead?


Answer: Running system commands is better done with
[`subprocess`](http://docs.python.org/3/library/subprocess.html), but if you
are using `os` already, why not just do

    
    
    pwd = os.getcwd()
    

[`os.getcwd()`](http://docs.python.org/3/library/os.html#os.getcwd) is
available on Windows and Unix.

