subprocess question

Andrew Berg bahamutzero8825 at gmail.com
Mon Dec 12 00:24:14 EST 2011


On 12/11/2011 10:39 PM, jyoung79 at kc.rr.com wrote:
> And another question - why can't I use the tilde as a shortcut to the home directory?
Because subprocess doesn't use the shell (which is what expands the
tilde to the invoking user's home directory). I recommend using
os.path.join and os.environ anyway.

p = subprocess.Popen(['du', '-sh', os.path.join(os.environ['home'],
'.Trash')], stdout=subprocess.PIPE)

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0



More information about the Python-list mailing list