what's the command for (cd ..) in python
Terry Reedy
tjreedy at udel.edu
Fri Sep 9 13:35:37 EDT 2011
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
More information about the Python-list
mailing list