Re: Newbie need help

From: Scott David Daniels (Scott.Daniels_at_Acm.Org)
Date: 04/06/04


Date: Mon, 05 Apr 2004 15:04:00 -0700

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@Acm.Org


Relevant Pages

  • Re: String literals in Java
    ... """ can have escape sequences like ... any normal string. ... characters: a backslash and a lowercase "n". ...
    (comp.lang.java.programmer)
  • Re: SendKey problem with doubleused keys
    ... > one of the backslash characters is changed to its correspondent 'non Alt Gr' ... > the real case of the string characters given to be sent. ...
    (microsoft.public.vb.winapi)
  • SendKey problem with doubleused keys
    ... one of the backslash characters is changed to its correspondent 'non Alt Gr' ... the real case of the string characters given to be sent. ...
    (microsoft.public.vb.winapi)
  • inserting "" & chr$(10) in MSSQL
    ... I try to insert a string out of vb 6.0 which contains a backslash, ... enormous performance loss..... ...
    (microsoft.public.data.ado)
  • Re: Prothon should not borrow Python strings!
    ... """It does not make sense to have a string without knowing what encoding ... same cul de sac as Python. ... Prothon_String_As_ASCII // raises error if there are high characters ... Python's split between byte strings and Unicode strings is ...
    (comp.lang.python)