Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82567
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Subject | Portable code: ‘from __future__ import unicode_literals’ a good idea? (was: Portable code: __import__ demands different string types between 2 and 3) |
| Date | 2014-12-16 11:42 +1100 |
| References | <85wq5tpe0g.fsf@benfinney.id.au> <CABicbJKZ9XhhXAwQZrHrb8HUa-4QoKf5jT96msNxeuoDbMzVSg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16988.1418690560.18130.python-list@python.org> (permalink) |
Devin Jeanpierre <jeanpierreda@gmail.com> writes:
> On Sun, Dec 14, 2014 at 11:29 PM, Ben Finney <ben+python@benfinney.id.au> wrote:
> > from __future__ import unicode_literals
>
> Ordinarily, for 2.x/3.3+ code I would suggest not doing this --
> instead, b'...' for bytes, u'...' for unicode, and '...' for native
> "string" type (bytes on 2.x, unicode on 3.x). This is the main benefit
> of the u'...' syntax addition.
That latter point would seemingly also apply to ‘from __future__ import
unicode_literals’, so is moot in this context.
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.
--
\ “I disapprove of what you say, but I will defend to the death |
`\ your right to say it.” —Evelyn Beatrice Hall, _The Friends of |
_o__) Voltaire_, 1906 |
Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Portable code: ‘from __future__ import unicode_literals’ a good idea? (was: Portable code: __import__ demands different string types between 2 and 3) Ben Finney <ben+python@benfinney.id.au> - 2014-12-16 11:42 +1100
csiph-web