Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56662
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Subject | Re: Unicode Objects in Tuples |
| Date | 2013-10-11 19:30 +1100 |
| References | <CAP=-cKU6Xkt_rm4VYh7NfXLSfUDG7FZQXHz+U12gP6fbkdhxbQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.994.1381480253.18130.python-list@python.org> (permalink) |
Stephen Tucker <stephen_tucker@sil.org> 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))
(<class 'str'>, <class 'str'>)
>>> 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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Unicode Objects in Tuples Ben Finney <ben+python@benfinney.id.au> - 2013-10-11 19:30 +1100
csiph-web