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

2012-06-28 Thread Laurent Pointal
Sergi Pasoev wrote: > 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

Re: 回复: how can I implement "cd" like shell in Python?

2012-06-28 Thread Alister
On Thu, 28 Jun 2012 20:28:40 +0800, Alex chen wrote: > 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 > > > That would not only be needlesly re-inventing the wheel but making it square in the

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

2012-06-28 Thread Evan Driscoll
On 6/28/2012 7:28, Alex chen wrote: > 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 You "can't" do this; a program the shell runs cannot affect the shell's execution. What you have to do is have s

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

2012-06-28 Thread Alex chen
OK,I see! Thank you everyone. -- Original -- From: "Evan Driscoll"; Date: Thu, Jun 28, 2012 10:27 PM To: "Alex chen"; Cc: "d"; "python-list"; Subject: Re: how can I implement "cd" like shell in

Re: 回复: how can I implement "cd" like shell in Python?

2012-06-28 Thread Kushal Kumaran
Alex chen wrote: >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 > This cannot be done. Shells implement cd as a builtin, rather than a command such as /usr/bin/cd because there is no way to cha

?????? how can I implement "cd" like shell in Python?

2012-06-28 Thread Alex chen
lex Chen"; ????: "python-list"; : 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

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

2012-06-28 Thread Dave Angel
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 difficul

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

2012-06-28 Thread Christian Heimes
Am 28.06.2012 13:09, schrieb Sergi Pasoev: > 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: Please note that you can't change the working directory

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

2012-06-28 Thread Hans Mulder
On 28/06/12 13:09:14, Sergi Pasoev wrote: > 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]) >

how can I implement "cd" like shell in Python?

2012-06-28 Thread Sergi Pasoev
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

how can I implement "cd" like shell in Python?

2012-06-28 Thread ??????
how can I implement "cd" like shell in Python?-- http://mail.python.org/mailman/listinfo/python-list