Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82569 > unrolled thread
| Started by | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| First post | 2014-12-15 20:19 -0500 |
| Last post | 2014-12-16 00:19 -0800 |
| Articles | 2 — 2 participants |
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.
Re: Portable code: ‘from __future__ import unicode_literals’ a good idea? Ned Batchelder <ned@nedbatchelder.com> - 2014-12-15 20:19 -0500
Re: Portable code: 'from __future__ import unicode_literals' a good idea? wxjmfauth@gmail.com - 2014-12-16 00:19 -0800
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-12-15 20:19 -0500 |
| Subject | Re: Portable code: ‘from __future__ import unicode_literals’ a good idea? |
| Message-ID | <mailman.16990.1418692803.18130.python-list@python.org> |
On 12/15/14 7:42 PM, Ben Finney wrote: > As for the advice to avoid such a declaration, you're arguing against > the official guide for porting Python 2 code to 2-and-3 compatible code: > > For text you should either use the from __future__ import > unicode_literals statement or add a u prefix to the text literal. > > <URL:https://docs.python.org/3.4/howto/pyporting.html#text-versus-binary-data> > > So, the declarative import is specifically recommended. You'll need to > present a case for why I shouldn't follow that recommendation. What's wrong with this part of the recommendation?: "or add a u prefix to the text literal." Also, keep in mind, these recommendations are not infallible. They are sometimes written before there's been broad experience with the solution. Your use of __import__ puts you in a tiny minority of programs, so the recommendation that's good for 99% of code may not work for you. Be flexible. Do what works. -- Ned Batchelder, http://nedbatchelder.com
[toc] | [next] | [standalone]
| From | wxjmfauth@gmail.com |
|---|---|
| Date | 2014-12-16 00:19 -0800 |
| Subject | Re: Portable code: 'from __future__ import unicode_literals' a good idea? |
| Message-ID | <ad773902-f5b2-49ce-b095-ee175e5fc0bf@googlegroups.com> |
| In reply to | #82569 |
Le mardi 16 décembre 2014 02:20:52 UTC+1, Ned Batchelder a écrit : > > What's wrong with this part of the recommendation?: "or add a u prefix > to the text literal." > The u'' trick in Py2 does not work. Generally speaking, Python and its characters encoding model has never work correctly and coherently outside the ascii world, only a mountain of patches and workarounds. In Py3 this kind of behaviour just became more accute with dramatic consequences. jmf
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web