Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82567 > unrolled thread
| Started by | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| First post | 2014-12-16 11:42 +1100 |
| Last post | 2014-12-16 11:42 +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.
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
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2014-12-16 11:42 +1100 |
| Subject | Portable code: ‘from __future__ import unicode_literals’ a good idea? (was: Portable code: __import__ demands different string types between 2 and 3) |
| Message-ID | <mailman.16988.1418690560.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web