Changing a shell's current directory with python

Lawrence Oluyede raims at dot.com
Sun Dec 18 19:08:30 EST 2005


irIl 2005-12-18, Andy B. <abuecker at gmail.com> ha scritto:
> I've got a python utility that I want to change my shell's current
> directory based on criteria it finds.  I've scoured google and the
> python cookbook and can't seem to figure out if this is even possible.
>  So far, all my attempts have changed the current python session only.
>  Am I going to have to wrap this in a shell script?
>
> % pwd
> /var/tmp
> % myutil.py
> # do some stuff and cd to '/var/log'
> % pwd
> /var/log

Just look in the library:

import os
os.chdir("path")


-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"



More information about the Python-list mailing list