raw Strings from XML attributes
paul at prescod.net
Sat Jun 12 11:08:39 CEST 2004
Karen Loughran wrote:
> I'm reading a string attribute from an XML document. The string
> contains newline characters and is treated as raw.
> I'm trying to match it with a string read from a file which is identical
> . But because it isn't raw it won't match.
As Peter Otten points out, "rawness" is a concept that Python forgets as
soon as a string is loaded into memory.
r"abc" == "abc"
r"\123abc" == "\\123abc"
So your problem is something else. Perhaps you could use the "repr"
function to print out the representations of the two strings and that
will give you more information.
print string1 == string2
More information about the Python-list