Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31322
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'string.': 0.04; 'true)': 0.07; 'versions.': 0.07; 'python': 0.09; '__future__': 0.09; 'assumed': 0.09; "b''": 0.09; 'portable': 0.09; 'porting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '3.2,': 0.16; 'eckhardt': 0.16; 'literal,': 0.16; 'literal.': 0.16; 'literals': 0.16; 'nudge': 0.16; 'portably': 0.16; 'rationale': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:unicode': 0.16; 'string': 0.17; 'wrote:': 0.17; 'byte': 0.17; 'unicode': 0.17; 'import': 0.21; 'error.': 0.21; 'feature': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'wonder': 0.27; 'header:X-Complaints-To:1': 0.28; 'strings,': 0.29; "i'm": 0.29; 'code': 0.31; 'could': 0.32; 'to:addr:python- list': 0.33; 'something': 0.35; 'received:org': 0.36; 'drop': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'skip:u 10': 0.60; 'remove': 0.61; 'is.': 0.62; 'between': 0.63; 'surprise': 0.65 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Serhiy Storchaka <storchaka@gmail.com> |
| Subject | Re: portable unicode literals |
| Date | Mon, 15 Oct 2012 20:11:45 +0300 |
| References | <t8etk9-5h9.ln1@satorlaser.homedns.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 37.115.213.25 |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 |
| In-Reply-To | <t8etk9-5h9.ln1@satorlaser.homedns.org> |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2221.1350321135.27098.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350321135 news.xs4all.nl 6977 [2001:888:2000:d::a6]:54235 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31322 |
Show key headers only | View raw
On 15.10.12 16:05, Ulrich Eckhardt wrote: > I need a little nudge in the right direction, as I'm misunderstanding > something concerning string literals in Python 2 and 3. In Python 2.7, > b'' and '' are byte strings, while u'' is a unicode literal. In Python > 3.2, b'' is a byte string and '' is a unicode literal, while u'' is a > syntax error. > > This actually came as a surprise to me, I assumed that using b'' I could > portably create a byte string (which is true) and using u'' I could > portably create a unicode string (which is not true). This feature would > help porting code between both versions. While this is a state I can > live with, I wonder what the rationale for this is. from __future__ import unicode_literals And now you can portable use b'' for a byte string and '' for a unicode string. When you will drop Python 2 support then just remove import from __future__.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
portable unicode literals Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-15 15:05 +0200
Re: portable unicode literals Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-15 13:26 +0000
Re: portable unicode literals Dave Angel <d@davea.name> - 2012-10-15 09:32 -0400
Re: portable unicode literals Alex Strickland <sscc@mweb.co.za> - 2012-10-15 15:41 +0200
Re: portable unicode literals Duncan Booth <duncan.booth@invalid.invalid> - 2012-10-16 08:44 +0000
Re: portable unicode literals Serhiy Storchaka <storchaka@gmail.com> - 2012-10-15 20:11 +0300
csiph-web