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: 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 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Ulrich Eckhardt Subject: Re: portable unicode literals References: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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