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


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

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

Started byDave Angel <d@davea.name>
First post2012-06-28 08:12 -0400
Last post2012-06-28 08:12 -0400
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how can I implement "cd" like shell in Python? Dave Angel <d@davea.name> - 2012-06-28 08:12 -0400

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

FromDave Angel <d@davea.name>
Date2012-06-28 08:12 -0400
SubjectRe: how can I implement "cd" like shell in Python?
Message-ID<mailman.1599.1340885548.4697.python-list@python.org>
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

[toc] | [standalone]


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


csiph-web