Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82569
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Subject | Re: Portable code: ‘from __future__ import unicode_literals’ a good idea? |
| Date | 2014-12-15 20:19 -0500 |
| References | <85wq5tpe0g.fsf@benfinney.id.au> <CABicbJKZ9XhhXAwQZrHrb8HUa-4QoKf5jT96msNxeuoDbMzVSg@mail.gmail.com> <85oar4pgrn.fsf_-_@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16990.1418692803.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
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
csiph-web