path backslash escaping trouble
Sion Arrowsmith
siona at chiark.greenend.org.uk
Tue Jul 10 08:02:11 EDT 2007
placid <Bulkan at gmail.com> wrote:
>I have these files; [ ... ]
>
>MergeType::::codefromlabel::::
>BLname::::BUILDMODS::::
>OldLname::::::::
>BaseVersion::::6.9.1.24A::::
>RequiredRelease::::6.10.1.3::::
>Description::::::::
>FixRelation::::::::
>Dependencies::::::::
>LpAffected::::No::::
>CodeReview::::FirstName LastName::::
>Testing::::Compile/Build;Designer;Smoketests;::::
>OtherTesting::::::::
>Vobs::::ipsupport;::::
>Elements::::\ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3::::
>
>i read this whole file into a string so i can search for the value of
>Elements which is
>\ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3
>
>but this path is escaped
>\\ipsupport\\ipbuild\\Wizard\\build.pl@@\\main\\buildmods\\3
How are you reading the file in? Are you absolutely sure that the
escaping appears *in the string*, and isn't being done by whatever
you're using to inspect it?
Consider:
>>> s = open('/tmp/Elements').read()
>>> s
'Elements::::\\ipsupport\\ipbuild\\Wizard\\build.pl@@\\main\\buildmods\\3::::\n'
>>> len(s)
70
Now, if those backslashes had *really* been escaped, the string would be
length 77, wouldn't it?
>>> s.find('\\\\')
-1
And find() can't find any double-backslashes in there.
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
"Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list