转发:Re:how can I implement "cd" like shell in Python?
梦幻草
wustcsvstudio at vip.qq.com
Thu Jun 28 07:39:30 EDT 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120628/0973cc3c/attachment.html>
More information about the Python-list
mailing list