chdir questions
Evan Simpson
evan at 4-am.com
Sun Feb 6 13:13:50 EST 2000
Patrick K Moorman <khadji at pld.com> wrote in message
news:Bmin4.4589$NS3.14557 at newsfeed.slurp.net...
> I know this is must be an easy one but how do I use os.chdir? I have
tried
> many different ways of listing the path but no matter how I type it I get
an
> error. Most common is either:
>
> >>> os.chdir(C:\temp)
> File "<string>", line 1
> os.chdir(C:\temp)
Is your previous experience coding with shell scripts or a language like
Rebol? You will need to adjust some of your basic concepts for Python.
In Python you need to put quotes around text which is not a keyword or a
name for a Python object. Also, backslashes ('\') are used to "escape" the
next character, so '\t' is a tab character. Fortunately, Python file
functions accept forward-slashed filenames on all platforms.
For the above you would write either:
os.chdir('C:/temp')
...or...
os.chdir("C:/temp")
Cheers,
Evan @ digicool
More information about the Python-list
mailing list