Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82572

Re: Portable code: ‘from __future__ import unicode_literals’ a good idea?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'that?': 0.05; 'subject:code': 0.07; '"or': 0.09; 'mind,': 0.09; 'prefix': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'recommends': 0.09; 'will,': 0.09; 'works.': 0.09; 'api': 0.11; 'python': 0.11; '__future__': 0.16; 'advice,': 0.16; 'clears': 0.16; 'finney': 0.16; 'literal.': 0.16; 'porting': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:import': 0.16; 'subject:skip:u 10': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'trying': 0.19; 'later': 0.20; 'import': 0.22; 'saying': 0.22; 'header:User- Agent:1': 0.23; "shouldn't": 0.24; 'unicode': 0.24; 'question': 0.24; 'code:': 0.26; 'header:X-Complaints-To:1': 0.27; 'specifically': 0.29; 'statement': 0.30; "i'm": 0.30; 'code': 0.31; 'writes:': 0.31; 'compatible': 0.32; 'text': 0.33; 'url:python': 0.33; 'advice': 0.35; 'equal': 0.35; "who's": 0.35; 'but': 0.35; 'add': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'wrong': 0.37; 'so,': 0.37; 'ben': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'according': 0.40; 'skip:u 10': 0.60; 'url:3': 0.61; "you're": 0.61; 'first': 0.61; "you'll": 0.62; 'such': 0.63; 'our': 0.64; 'different': 0.65; 'skip:\xe2 10': 0.65; 'within': 0.65; 'url:4': 0.69; 'subjectcharset:utf-8': 0.72; 'batchelder': 0.84; 'liberty': 0.84; 'received:125': 0.84; 'subject:good': 0.84; 'subject::': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Portable code: ‘from __future__ import unicode_literals’ a good idea?
Date Tue, 16 Dec 2014 13:31:50 +1100
References <85wq5tpe0g.fsf@benfinney.id.au> <CABicbJKZ9XhhXAwQZrHrb8HUa-4QoKf5jT96msNxeuoDbMzVSg@mail.gmail.com> <85oar4pgrn.fsf_-_@benfinney.id.au> <m6o1bm$qgc$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
Cancel-Lock sha1:ha84AB/RSnA0yc39F5aeSQ4r48Y=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16993.1418697119.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418697119 news.xs4all.nl 2893 [2001:888:2000:d::a6]:33031
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82572

Show key headers only | View raw


Ned Batchelder <ned@nedbatchelder.com> writes:

> 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."

Who's saying there's anything wrong with that? Not I.

My question is, what's wrong with the first part such that Devin
recommends against it?

> Also, keep in mind, these recommendations are not infallible.

Yes, Devin clears up in a later message that the official guide provides
no advice for the case where an API needs ‘bytes’ in Python 2 but
Unicode in Python 3.

> Be flexible.  Do what works.

Good advice, but nothing different from what I'm already trying to do.

-- 
 \        “[R]ightful liberty is unobstructed action, according to our |
  `\        will, within limits drawn around us by the equal rights of |
_o__)                                 others.” —Thomas Jefferson, 1819 |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Portable code: ‘from __future__ import unicode_literals’ a good idea? Ben Finney <ben+python@benfinney.id.au> - 2014-12-16 13:31 +1100

csiph-web