Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86164

Re: calling subprocess

Date 2015-02-22 22:14 +0000
From Tim Golden <mail@timgolden.me.uk>
Subject Re: calling subprocess
References <edfc56d5-8696-49d0-8b71-69044bbab1f5@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.19034.1424643312.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

calling subprocess jkuplinsky@gmail.com - 2015-02-22 14:06 -0800
  Re: calling subprocess Tim Golden <mail@timgolden.me.uk> - 2015-02-22 22:14 +0000
  Re: calling subprocess Chris Angelico <rosuav@gmail.com> - 2015-02-23 09:21 +1100
    Re: calling subprocess jkuplinsky@gmail.com - 2015-02-22 17:13 -0800
      Re: calling subprocess Chris Angelico <rosuav@gmail.com> - 2015-02-23 12:31 +1100
      Re: calling subprocess Dave Angel <davea@davea.name> - 2015-02-22 21:38 -0500
      Re: calling subprocess Dave Angel <davea@davea.name> - 2015-02-22 22:07 -0500

csiph-web