[Tutor] Python Fails to Change Directory
Andrew Jahn
andrew.jahner at gmail.com
Sun Apr 15 06:02:48 CEST 2012
Hi all,
I am attempting to use a Python program to change into a specified
directory before executing some commands. However, when I call the Python
program from my Unix shell (tcsh) using a command such as
"python myprogram.py"
It runs without changing directory. Just to clarify, the lines of code in
question are the following:
import os
MyDir = "/usr/local/myDir"
os.system("cd "+myDir)
I have also tried "os.chdir(MyDir)", but that doesn't work either - it just
runs without actually changing directory. As a side note, when I run the
same commands above within the Python interactive environment, it works
just fine.
I am running Python version 2.4.
Thanks!
-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120415/6a4cfe7e/attachment.html>
More information about the Tutor
mailing list