Change directory not successfully done

Samuel Yin samuel.yin at 163.com
Thu Nov 10 21:16:02 EST 2005


Hi, guys,

This should be a simple problem, but I just can not resolve it. I just
want to use a python script to change my working directory. see my
following code:

# mycd.py
1) destdir = "xxxxxxxx"
2) command = "cd "+ destdir
3) os.system(command)
4) os.chdir(destdir)

But neither 3) nor 4) is used, I just can not change the directory after
execute mycd.py. This remind me of bash script. If you change directory
in your bash script file, it will only impact the sub process of that
script, except that you invoke that bash script by ./script_file_name.
But what should I do in the case of python script?

Thanks and Regards

Samuel Yin




More information about the Python-list mailing list