Unicode Objects in Tuples

Stephen Tucker stephen_tucker at sil.org
Fri Oct 11 04:16:36 EDT 2013


I am using IDLE, Python 2.7.2 on Windows 7, 64-bit.

I have four questions:

1. Why is it that
     print unicode_object
displays non-ASCII characters in the unicode object correctly, whereas
     print (unicode_object, another_unicode_object)
displays non-ASCII characters in the unicode objects as escape sequences
(as repr() does)?

2. Given that this is actually *deliberately *the case (which I, at the
moment, am finding difficult to accept), what is the neatest (that is, the
most Pythonic) way to get non-ASCII characters in unicode objects in tuples
displayed correctly?

3. A similar thing happens when I write such objects and tuples to a file
opened by
     codecs.open ( ..., "utf-8")
I have also found that, even though I use  write  to send the text to the
file, unicode objects not in tuples get their non-ASCII characters sent to
the file correctly, whereas, unicode objects in tuples get their characters
sent to the file as escape sequences. Why is this the case?

4. As for question 1 above, I ask here also: What is the neatest way to get
round this?

Stephen Tucker.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131011/50f0e3b6/attachment.html>


More information about the Python-list mailing list