calling subprocess
Tim Golden
mail at timgolden.me.uk
Sun Feb 22 17:14:24 EST 2015
On 22/02/2015 22:06, jkuplinsky at gmail.com wrote:
> Hi,
>
> I thought this would be easy:
>
>
> for subprocess import call call (['cd', r'C:\apps'], shell = True)
>
>
> It doesn't work -- tried with/without prefix r, escaped backslashes,
> triple quotes, str(), .. nothing seems to work (it doesn't complain,
> but it doesn't change directories either) -- what am I doing wrong?
Two things:
1) All you're doing is running up a subprocess, changing directory
*within it* and then closing it. (Altho' good job spotting that you'd
need shell=True if you did indeed want to do what you're doing here).
2) Use os.chdir: that's what it's there for
TJG
More information about the Python-list
mailing list