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


Groups > comp.lang.python > #31299

Re: portable unicode literals

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'true)': 0.07; 'versions.': 0.07; 'python': 0.09; 'assumed': 0.09; "b''": 0.09; 'porting': 0.09; 'cc:addr:python-list': 0.10; '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; 'subject:unicode': 0.16; 'syntax,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'byte': 0.17; 'unicode': 0.17; 'error.': 0.21; '2.x': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'feature': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'am,': 0.27; 'wonder': 0.27; 'strings,': 0.29; "i'm": 0.29; 'code': 0.31; 'could': 0.32; 'thanks': 0.34; 'something': 0.35; 'subject:: ': 0.38; 'easier': 0.38; 'received:192': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'is.': 0.62; 'between': 0.63; 'surprise': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84
Date Mon, 15 Oct 2012 09:32:22 -0400
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0
MIME-Version 1.0
To Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Subject Re: portable unicode literals
References <t8etk9-5h9.ln1@satorlaser.homedns.org>
In-Reply-To <t8etk9-5h9.ln1@satorlaser.homedns.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:qqooyKNr1IwhHYvDE6f9Nru/LsgQetReb6x8vLml3AO 4JV4yl4xR7D5mrZjl4kM/93bXVJZN9NKVgEPhkuGZsWstol1qA qiA8cIVoRf1XyvQe49iHAdYNyqFgCovxyLX2PhgdVcodtjSuic RFztND2rC55FEGb4GDWNlBzeMyu7pLV883vGNIlcW8dVDDabYn YFJ2EQMYi1CS/lrQDChvAZpEjhaVg6CHjgy1ITnJFGy1h7qNw9 XvjiwPFkTsje9cI0LwUehkX/KAyjr5OU/YItQcOEaWNpup8V9w SxBms3YzbtjSA2jpjz2pbu8xItjB88tyROU3eL1Xw0NwzkbQQ= =
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
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.2202.1350307975.27098.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350307975 news.xs4all.nl 6923 [2001:888:2000:d::a6]:39175
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31299

Show key headers only | View raw


On 10/15/2012 09:05 AM, Ulrich Eckhardt wrote:
> Hi!
>
> 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.
>
> !puzzled thanks
>
> Uli

Python 3.3 added that syntax, for easier porting.  You can now use
u"xyz" for a unicode string in both 2.x and 3.3

-- 

DaveA

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


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