Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Pyhon 2.x or 3.x, which is faster? Date: Wed, 9 Mar 2016 10:42:53 -0500 Lines: 71 Message-ID: References: <87d1r6iltx.fsf@elektro.pacujo.net> <56de28a1$0$1604$c3e8da3$5496439d@news.astraweb.com> <56de57b5$0$1590$c3e8da3$5496439d@news.astraweb.com> <56df6873$0$1588$c3e8da3$5496439d@news.astraweb.com> <56df87f7$0$1620$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de IcSpY5UsEUSxAG+EYl5L2gQ1mFOAsSLDDf/BbPFozAbA== Return-Path: 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; 'resulting': 0.04; 'error:': 0.05; 'initialize': 0.05; 'sys': 0.05; 'encoding:': 0.07; 'plenty': 0.07; 'ugly': 0.07; 'utf-8': 0.07; '(ie.': 0.09; '172': 0.09; 'mode,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'subject:which': 0.09; 'python': 0.10; 'jan': 0.11; 'buggy': 0.16; 'decade,': 0.16; 'fatal': 0.16; 'marker': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'unicode.': 0.16; 'wrote:': 0.16; 'string': 0.17; 'bytes': 0.18; 'char': 0.18; 'odd': 0.18; 'skip': 0.18; '>>>': 0.20; 'latter': 0.22; 'terminate': 0.22; 'tkinter': 0.22; 'am,': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; '----------': 0.25; "i've": 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'error': 0.27; 'handling': 0.27; 'least': 0.27; 'prints': 0.29; 'subset': 0.29; 'windows,': 0.29; '(including': 0.30; 'code': 0.30; "can't": 0.32; 'getting': 0.33; 'run': 0.33; 'displayed': 0.33; 'idle': 0.33; "i'll": 0.33; 'changing': 0.34; 'file': 0.34; 'handle': 0.34; 'gives': 0.35; 'text': 0.35; 'unicode': 0.35; 'unknown': 0.35; 'depends': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'application': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'claim': 0.61; 'received:96': 0.63; 'more': 0.63; 'series': 0.65; 'believe': 0.66; 'contact': 0.66; 'results.': 0.67; '8bit%:96': 0.67; 'unusual': 0.72; 'euro': 0.75; 'gotten': 0.76; 'as:': 0.79; 'streams': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-96-227-207-81.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104426 On 3/9/2016 9:03 AM, BartC wrote: > I've just tried a UTF-8 file and getting some odd results. With a file > containing [three euro symbols]: > > =E2=82=AC=E2=82=AC=E2=82=AC > > (including a 3-byte utf-8 marker at the start), and opened in text mode= , > Python 3 gives me this series of bytes (ie. the ord() of each character= ): > > 239 > 187 > 191 > 226 > 8218 > 172 > 226 > 8218 > 172 > 226 > 8218 > 172 > > And prints the resulting string as: =C3=AF=C2=BB=C2=BF=C3=A2=E2=80=9A=C2= =AC=C3=A2=E2=80=9A=C2=AC=C3=A2=E2=80=9A=C2=AC. Although this latter > might depend on my console's code page setting. It definitely does. > Changing it to UTF-8 however (CHCP 65001 in Windows) CP65001 is MS's ugly pretense of unicode compatibility. It has been=20 known to be buggy for over a decade, though some people claim to have=20 gotten some use of it. > gives me this error when I run the program again: > > ---------- > Fatal Python error: Py_Initialize: can't initialize sys standard stream= s > LookupError: unknown encoding: cp65001 > > This application has requested the Runtime to terminate it in an unusua= l > way. > Please contact the application's support team for more information. > ---------- > So I think I'll skip Unicode handling to start off with! (I've already > had plenty of fun and games with it in the past.) At least on Windows, use IDLE for the BMP subset of unicode. tk and=20 hence tkinter and IDLE can handle any char in the BMP subset. I believe = that which are actually displayed and which are shown as boxes depends=20 on the font. On my US Win10 system: IDLE with Lucida Console: >>> s =3D '=E2=82=AC=E2=82=AC=E2=82=AC' >>> s '=E2=82=AC=E2=82=AC=E2=82=AC' In the console interpreter: '???' is printed. --=20 Terry Jan Reedy