thanks !But this method can not change the directory of the main process.For 
example:
the current directory is "/home/work/local/scripts",this directory have a 
python script file "cd.py"
after executing the script cd.py by "python cd.py ..",the current work 
directory has no changes,the path is still "/home/work/local/scripts"
 




------------------ Original ------------------
From: "Sergi Pasoev"; 
Date: 2012??6??28??(??????) ????7:09
To: "python-list"; 
Subject: how can I implement "cd" like shell in Python?



Do you mean to implement the cd command ? To what extent do you want to
implement it ? if what you want is just to have a script to change the
current working directory, it is as easy as this:


import sys
import os
os.chdir(sys.argv[1])

plus you could add some error-handling code.
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to