Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58182 > unrolled thread

Re: tuple __repr__ non-ascii characters

Started byChris Angelico <rosuav@gmail.com>
First post2013-11-01 02:06 +1100
Last post2013-11-01 02:06 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: tuple __repr__ non-ascii characters Chris Angelico <rosuav@gmail.com> - 2013-11-01 02:06 +1100

#58182 — Re: tuple __repr__ non-ascii characters

FromChris Angelico <rosuav@gmail.com>
Date2013-11-01 02:06 +1100
SubjectRe: tuple __repr__ non-ascii characters
Message-ID<mailman.1881.1383232009.18130.python-list@python.org>
On Fri, Nov 1, 2013 at 1:59 AM, Yaşar Arabacı <yasar11732@gmail.com> wrote:
> Is there a better way to handle this problem?

There is, but I don't know how easy it'll be. In Python 3, the repr of
a tuple will show Unicode strings as Unicode. :)

For what you're showing there, I'm not actually quite sure what's
going on. Is the string a Unicode string, or a byte string? If it's a
byte string (which I suspect, since it's coming up as \xfe and the
character you're showing us isn't U+00FE), then you have to worry
about encodings. If you're using it to store non-ASCII data, you
probably want to be using a Unicode string:

a = u"yaşar"

The best solution is definitely to move to Python 3, though - if you
can. Do you have much code to migrate, or are you starting fresh? Are
there any libraries/modules that you need that don't support Py3?

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web