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


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

Re: python 2.7 and unicode (one more time)

Started byChris Angelico <rosuav@gmail.com>
First post2014-11-20 21:47 +1100
Last post2014-11-20 21:47 +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: python 2.7 and unicode (one more time) Chris Angelico <rosuav@gmail.com> - 2014-11-20 21:47 +1100

#81069 — Re: python 2.7 and unicode (one more time)

FromChris Angelico <rosuav@gmail.com>
Date2014-11-20 21:47 +1100
SubjectRe: python 2.7 and unicode (one more time)
Message-ID<mailman.16013.1416480450.18130.python-list@python.org>
On Thu, Nov 20, 2014 at 8:40 PM, Francis Moreau <francis.moro@gmail.com> wrote:
> My question is: how should this be fixed properly ?
>
> A simple solution would be to force all strings passed to the
> logger to be unicode:
>
>   log.debug(u"%s: %s" % ...)
>
> and more generally force all string in my code to be unicode by
> using the 'u' prefix.

Yep. And then you may want to consider "from __future__ import
unicode_literals", which will make string literals represent Unicode
strings rather than byte strings. Basically the same as you're saying,
only without the explicit u prefixes.

This will also make your Py2 code behave more like the way your Py3
code does (as bare string literals are always Unicode strings in Py3).

ChrisA

[toc] | [standalone]


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


csiph-web