Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24607 > unrolled thread

转发:Re:how can I implement "cd" like shell in Python?

Started by"梦幻草" <wustcsvstudio@vip.qq.com>
First post2012-06-28 19:39 +0800
Last post2012-06-28 19:39 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  转发:Re:how can I implement "cd" like shell in Python? "梦幻草" <wustcsvstudio@vip.qq.com> - 2012-06-28 19:39 +0800

#24607 — 转发:Re:how can I implement "cd" like shell in Python?

From"梦幻草" <wustcsvstudio@vip.qq.com>
Date2012-06-28 19:39 +0800
Subject转发:Re:how can I implement "cd" like shell in Python?
Message-ID<mailman.1598.1340883579.4697.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web