Newbie need help
Scott David Daniels
Scott.Daniels at Acm.Org
Mon Apr 5 18:04:00 EDT 2004
Tony Ha wrote:
> ... instead of
>os.chdir("C:\Python23\Lib\site-packages\PythonCardPrototype\tools")
>you need
>os.chdir("C:\\Python23\\Lib\\site-packages\\PythonCardPrototype\\tools\\codeEditor")
> I also found out you can you u' raw string. i.e.
> os.chdir(u'C:\Python23\Lib\site-packages\PythonCardPrototype')
> this also work.
Nope, you just lucked out by using a different string.
the problem with using a backslash is that it normally an instruction to
the source translator to construct special characters. Because your
previous directory name included tools, you had a sequence with a
backslash followed by a lower case t. That is shorthand for a tab
(ASCII 9). As Peter Hansen tells you in another note, you can use
an r directly before the string to tell the source translator to
"treat backslashes as regular characters." So, you'll notice that,
for example, 'abc\tex' != r'abc\tex', but 'abc\Tex' == r'abc\Tex',
because '\t' is the tab character, not '\T'.
--
-Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list