Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'prefix': 0.09; 'true)': 0.09; '(it': 0.16; '22:06,': 0.16; 'complain,': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'here).': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'tjg': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'import': 0.22; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply- To:1': 0.27; 'tried': 0.27; "doesn't": 0.30; 'running': 0.33; 'but': 0.35; 'there': 0.35; 'doing': 0.36; 'hi,': 0.36; 'changing': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; 'email addr:gmail.com': 0.63; 'charset:windows-1252': 0.65; 'from:addr:mail': 0.83 Date: Sun, 22 Feb 2015 22:14:24 +0000 From: Tim Golden User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: calling subprocess References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424643312 news.xs4all.nl 2838 [2001:888:2000:d::a6]:38877 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86164 On 22/02/2015 22:06, jkuplinsky@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