Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81069
| References | <m4kcu8$ta8$1@ger.gmane.org> |
|---|---|
| Date | 2014-11-20 21:47 +1100 |
| Subject | Re: python 2.7 and unicode (one more time) |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16013.1416480450.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python 2.7 and unicode (one more time) Chris Angelico <rosuav@gmail.com> - 2014-11-20 21:47 +1100
csiph-web