navigating/changing directories

skip skip at
Thu Jan 6 10:24:02 CET 2005

A simple script like the one below lets me jump through a directory 
structure.  However, if I run it from /this/directory and within it to go to 
/a/totally/different/directory...  I'm still actually going to be in 
/this/directory when I exit the script.  Is it possible to have a script 
that can drop me off into a different directory than where I initiated it 

import os
process = 1
while (process):
    # Display directories
    for i in os.listdir(os.getcwd()):
        if (os.path.isdir(os.path.join(os.getcwd(),i))):
            print i

    # Change directory
    goto_dir = raw_input(": ")
    if (goto_dir in os.listdir(os.getcwd())):
        process = 0 # Exit

More information about the Python-list mailing list