Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'encoding': 0.05; 'subject:Python': 0.06; 'utf-8': 0.07; 'string': 0.09; 'literal': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"e"': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'source': 0.25; 'header:In-Reply-To:1': 0.27; 'point': 0.28; '"",': 0.31; '>>>>': 0.31; 'assert': 0.31; 'file': 0.32; '(most': 0.33; 'depends': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'length': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'between': 0.67; 'subjectcharset:utf-8': 0.72; 'jul': 0.74; 'otten': 0.84; 'sfxlen:4': 0.84; 'subject::': 0.85; '2013,': 0.91; 'pfxlen:big': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=CfYxutbl c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=5FYZ9MsUIQAA:10 a=kQW-FESv4KwA:10 a=ihvODaAuJD4A:10 a=jPJDawAOAc8A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=u0z_fz42dFwA:10 a=pGLkceISAAAA:8 a=oKAReO4098N5ukgJREQA:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 X-AUTH: mrabarnett:2500 Date: Sun, 12 Jan 2014 18:33:03 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: python-list@python.org CC: python-list@python.org Subject: Re: =?UTF-8?B?J1N0cmHDn2UnICgnU3RyYXNzZScpIGFuZCBQeXRob24gMg==?= References: <30dfa6f1-61b2-49b8-bc65-5fd18d498c38@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389551590 news.xs4all.nl 2911 [2001:888:2000:d::a6]:45081 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63793 On 2014-01-12 08:31, Peter Otten wrote: > wxjmfauth@gmail.com wrote: > >>>>> sys.version >> 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] >>>>> s = 'Straße' >>>>> assert len(s) == 6 >>>>> assert s[5] == 'e' >>>>> >> >> jmf > > Signifying nothing. (Macbeth) > > Python 2.7.2+ (default, Jul 20 2012, 22:15:08) > [GCC 4.6.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> s = "Straße" >>>> assert len(s) == 6 > Traceback (most recent call last): > File "", line 1, in > AssertionError >>>> assert s[5] == "e" > Traceback (most recent call last): > File "", line 1, in > AssertionError > > The point is that in Python 2 'Straße' is a bytestring and its length depends on the encoding of the source file. If the source file is UTF-8 then 'Straße' is a string literal with 7 bytes between the single quotes.