I just want to write a python program,it can be called in the linux terminal 
like the command "cd" to change the directory of the shell terminal 




------------------ ???????? ------------------
??????: "Dave Angel"<d...@davea.name>;
????????: 2012??6??28??(??????) ????8:12
??????: "Alex Chen"<wustcsvstu...@vip.qq.com>; 
????: "python-list"<python-list@python.org>; 
????: Re: how can I implement "cd" like shell in Python?



On 06/28/2012 05:30 AM, ?????? wrote:
> how can I implement "cd" like shell in Python?
>

import os
os.chdir("newdirectory")


But the more important question is why you want to.  Inside a Python
program, many people find that changing directory causes unexpected
difficulties, and they simply keep track of a full path instead, using
various os.path functions to manage it.

And once the python program ends, the shell should have no knowledge of
what you changed it to.

Now, a particular shell program might have some convention that allows a
program to inform it what directory to continue in.  But that's a
question about that shell, not about Python.  And you never said what
your environment is.


So give some more specifics to your needs, and somebody is likely to
know an approach.



-- 

DaveA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to