Re: [Tutor] Arrgh! Paths on windows!
Magnus Lycka
magnus at thinkware.se
Tue Feb 24 11:11:20 EST 2004
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
>
--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus at thinkware.se
More information about the Tutor
mailing list