I see...
This works:

import re

with open('test.xml', 'r') as f:
print re.sub(r'(^(\'|\")|(\'|\")$)', '', repr(f.read()).replace('\\n', '\n'))

But, repr can still print binary characters. Opening libexpat.so shows all sorts of crazy characters like \x00.

random832@fastmail.us wrote:
On Thu, Aug 1, 2013, at 16:05, David Mertz wrote:
In what sense is "\n" "not printable in repr()"?!

Because it prints as \n instead of as itself, doesn't it? Or is that
only in Python 2?


Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.