[Tutor] Arrgh! Paths on windows!
vmonkey
vmonkey at earthlink.net
Tue Feb 24 11:24:14 EST 2004
Thanks, your solution worked. Is there a better way for me to do this
in the future?
Magnus Lycka wrote:
>The way it looks in your mail: with a line break after "Local",
>there is certainly EndOfLine in a single-quoted string. I get
>that error just as I expect. If I put the whole path on one line,
>I get just the normalized path I expect.
>
>Python is (quite deliberately) picky on whitespace handling,
>but all languages I know of are picky about linebreaks in strings.
>
>If you want to split the long string to fit in fewer columns,
>you need to quote each segment separately.
>
>
>
>>>>tmp = os.path.normpath("c:/Documents and Settings/"
>>>>
>>>>
> "Joe Blow/Local "
> "Settings/Temporary Internet Files")
>
>Be careful to preserve the whitespaces as well. "Local " != "Local"
>
>-----Ursprungligt meddelande-----
>Från: vmonkey <vmonkey at earthlink.net>
>Skickat: 2004-02-24 16:54:25
>Till: tutor at python.org
>Ämne: [Tutor] Arrgh! Paths on windows!
>
>
>
>
>>What is wrong with the following lines of code?
>>
>>import os
>>
>>tmp = os.path.normpath("c:/Documents and Settings/Joe Blow/Local
>>Settings/Temporary Internet Files")
>>
>>It SHOULD create a path properly formatted for windows in the variable
>>tmp. But I get this error whenever I run it:
>>
>>SyntaxError: EOL while scanning single-quoted string
>>
>>Can anyone help me with this?
>>
>>
>>_______________________________________________
>>Tutor maillist - Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>
>
>
>
>
More information about the Tutor
mailing list