How do I change directory in python so it remains after running the script?
Question: I'm trying to change the terminal directory through a python script. I've seen
this [post](http://stackoverflow.com/questions/431684/how-do-i-cd-in-
python/431715 "post") and others like it so I know about os.chdir, but it's
not working the way I'd like. os.chdir appears to change the directory, but
only for the python script. For instance I have this code.

    
    
    #! /usr/bin/env python
    import os
    
    os.chdir("/home/chekid/work2/")
    print os.getcwd()
    

Unfortunately after running I'm still in the directory of the python script
(e.g. /home/chekid) rather than the directory I want to be in. See below.

    
    
    gandalf(pts/42):~> pwd
    /home/chekid
    
    gandalf(pts/42):~> ./changedirectory.py
    /home/chekid/work2
    
    gandalf(pts/42):~> pwd
    /home/chekid
    

Any thoughts on what I should do?

_Edit_ : Looks like what I'm trying to do doesn't exist in 'normal' python. I
did find a work around, although it doesn't look so elegant to me.

    
    
     cd `./changedirectory.py`
    


Answer: The current working directory is an attribute of a process. It cannot be
changed by another program, such as changing the current working directory in
your shell by running a separate Python program. This is why `cd` is _always_
a shell built-in command.

