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


Groups > comp.lang.python > #13032

Re: what's the command for (cd ..) in python

From Terry Reedy <tjreedy@udel.edu>
Subject Re: what's the command for (cd ..) in python
Date 2011-09-09 13:35 -0400
References <mailman.903.1315570033.27778.python-list@python.org> <4e6a0e8e$0$29967$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.911.1315590009.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 9/9/2011 9:03 AM, Steven D'Aprano wrote:
> kaustubh joshi wrote:
>
>> Hello friends,
>>                           How do we carry out the command "*cd ..*" in
>> python?
>
> import os
> os.chdir('..')
>
> But think carefully before doing this. Some functions may be confused if you
> change directories while they are running. You may be better off staying in
> the same directory, and adjusting the path names to the files as you work
> with them.

Or, use it once at the top of the main module, with an absolute path, to 
make sure you start at a known place where you want to start.

-- 
Terry Jan Reedy

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


Thread

what's the command for (cd ..) in python kaustubh joshi <kandrjoshi@gmail.com> - 2011-09-09 14:07 +0200
  Re: what's the command for (cd ..) in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-09 23:03 +1000
    Re: what's the command for (cd ..) in python Terry Reedy <tjreedy@udel.edu> - 2011-09-09 13:35 -0400
    Re: what's the command for (cd ..) in python "Waldek M." <wm@localhost.localdomain> - 2011-09-10 12:32 +0200
      Re: what's the command for (cd ..) in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-10 21:11 +1000
        Re: what's the command for (cd ..) in python "Waldek M." <wm@localhost.localdomain> - 2011-09-10 15:57 +0200
          Re: what's the command for (cd ..) in python Cameron Simpson <cs@zip.com.au> - 2011-09-11 09:50 +1000

csiph-web