I am on Mac OS terminal console running Python 2.7
>>> print 'One' # Nice
One
>>> print 'Один' # Unicode strings prints just fine also
Один
>>> print ['One', 'Two'] # List of ascii strings prints just fine
['One', 'Two']
>>> print ['Один', 'Два'] # List of unicode strings prints with codes
['\xd0\x9e\xd0\xb4\xd0\xb8\xd0\xbd', '\xd0\x94\xd0\xb2\xd0\xb0']
How can I avoid getting unicode escape sequences and just get following as an output for the last command?
>>> print ['One', 'Two'] # How can I get this??
[u'Один', u'Два']
I know, I can run a cycle through the list, but in reality my structure is much more complex, so I need a lean command to print the entire structure without encoding letters.
I need this for debugging of complicated data structures. When strings are in escape codes - they are totally unreadable. Is there any library/function which is capable to print without encoding. My console seems to be able to display such characters just fine.
repr()). Note that explanation of the accepted answer is severely lacking -- you should review the explanation and references in the previous question.