raw Strings from XML attributes

Paul Prescod paul at prescod.net
Sat Jun 12 05:08:39 EDT 2004


Karen Loughran wrote:

> 
> Hiya,
> 
> 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 repr(string1)
print repr(string2)
print string1 == string2

  Paul Prescod






More information about the Python-list mailing list