<div> </div><div><includetail><div><br></div><div><br></div><div>thanks !But this method can not change the directory of the main process.For example:</div><div>the current directory is "/home/work/local/scripts",this directory have a python script file "cd.py"</div><div>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"</div><div> </div><div><br></div><div><br></div><div style="padding: 2px 0px; font-family: Arial Narrow; font-size: 12px;">------------------ Original ------------------</div><div style="background: rgb(239, 239, 239); padding: 8px; font-size: 12px;"><div><b>From:</b> "Sergi Pasoev"<s.pasoev@gmail.com></s.pasoev@gmail.com>; </div><div><b>Date:</b> 2012年6月28日(星期四) 晚上7:09</div><div><b>To:</b> "python-list"<python-list@python.org></python-list@python.org>; </div><div><b>Subject:</b> how can I implement "cd" like shell in Python?</div></div><div><br></div>Do you mean to implement the cd command ? To what extent do you want to<br>implement it ? if what you want is just to have a script to change the<br>current working directory, it is as easy as this:<br><br><br>import sys<br>import os<br>os.chdir(sys.argv[1])<br><br>plus you could add some error-handling code.<br>-- <br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.<wbr>python.org/m<wbr>ailman/listi<wbr>nfo/python-l<wbr>ist</a><br>  <style>#mailContentContainer .txt {height:auto;}</style></includetail></div>