Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'fixes': 0.07; '*the': 0.09; 'escape': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'worse': 0.09; 'python': 0.11; 'windows': 0.15; '2.7.2': 0.16; 'finney': 0.16; 'idle,': 0.16; 'non-ascii': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'repr()': 0.16; 'subject:Unicode': 0.16; ':-)': 0.16; 'not,': 0.20; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'questions:': 0.24; 'stephen': 0.24; 'unicode': 0.24; 'switch': 0.26; 'header:X-Complaints-To:1': 0.27; 'characters': 0.30; "i'm": 0.30; '(which': 0.31; 'men': 0.31; 'sea': 0.31; 'tuples': 0.31; 'writes:': 0.31; 'objects': 0.35; 'ben': 0.38; 'displays': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'major': 0.40; 'most': 0.60; 'skip:* 10': 0.61; '(that': 0.65; 'fact,': 0.69; 'calm': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Unicode Objects in Tuples Date: Fri, 11 Oct 2013 19:30:40 +1100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:s6Wz/l5WGRWAJ4xT0Ms4SlGnr4o= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381480253 news.xs4all.nl 15929 [2001:888:2000:d::a6]:37377 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56662 Stephen Tucker writes: > I am using IDLE, Python 2.7.2 on Windows 7, 64-bit. Python 2 is not as good at Unicode as Python 3. In fact, one of the major reasons to switch to Python 3 is that it fixes Unicode behaviour that was worse in Python 2. > I have four questions: > > 1. Why is it that […] > print (unicode_object, another_unicode_object) > displays non-ASCII characters in the unicode objects as escape sequences > (as repr() does)? Python 3 behaves correctly for that:: >>> foo = "I ♡ Unicode" >>> bar = "I ♥ Unicode" >>> (type(foo), type(bar)) (, ) >>> print(foo) I ♡ Unicode >>> print(bar) I ♥ Unicode >>> print((foo, bar)) ('I ♡ Unicode', 'I ♥ Unicode') > 2. Given that this is actually *deliberately *the case (which I, at > the moment, am finding difficult to accept) I'm pretty sure it is not, since this is corrected in Python 3. > what is the neatest (that is, the most Pythonic) way to get non-ASCII > characters in unicode objects in tuples displayed correctly? Switch to Python 3 :-) -- \ “Timid men prefer the calm of despotism to the boisterous sea | `\ of liberty.” —Thomas Jefferson | _o__) | Ben Finney