Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: What's the best/neatest way to get Unicode data from a database into a grid cell? Date: Mon, 8 Feb 2016 21:57:29 +1100 Lines: 18 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de nbp2fgiNTTRA8oH2F2N4nQWAkwWdHMXijPRBl6Dgm/7g== 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; 'received:209.85.223': 0.03; 'modify': 0.04; 'clause': 0.07; 'except:': 0.07; 'cc:addr :python-list': 0.09; 'situation.': 0.09; 'subject:into': 0.09; 'python': 0.10; 'exception': 0.13; 'subject: \n ': 0.15; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Unicode': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fairly': 0.22; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'compatible': 0.27; 'switch': 0.27; 'message-id:@mail.gmail.com': 0.27; 'code:': 0.29; 'subject:/': 0.30; 'anywhere': 0.30; 'code': 0.30; 'becomes': 0.30; 'e.g.': 0.30; 'case,': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'available.': 0.37; 'received:209': 0.38; 'subject:from': 0.39; 'subject:the': 0.39; 'care': 0.60; 'your': 0.60; 'avoid': 0.61; 'subject:get': 0.81; 'chrisa': 0.84; 'phoenix': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=fyxDeJ0MHhC+gabOsZ6d6ijlp2nfnKG47QMdoXTijv4=; b=NE5C/Cvnla5zwKXy/crX+33TzKkJkcs/yr+cxyoH5T13/I2TDZXPK3BYEUih/rxXuM fcHIimuM08aDsBCjGoNc5k2uNeSfuXefpJvhF112tNnMP9nMCRgfoJOJfkbQV6aRmFkZ GntFJUuDgzT2iOELap9iQl0ejj9bun8LHFFZeblx6MsJhAwwyJPbGL7nmxWV8T6lHZ3h u60Z3W0zjc6eG+lz1z/2IEQWh+L5oA9i8pwVYPoXb6B6lrOs51L1wSj5bZaH/Tey8+On KFLsS2C6R8LB2xJSXEHIxKCBiG86m87cvZVjiK3Z6BIFCY601zEdZjYVLna9bR9cEJa+ 8eDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=fyxDeJ0MHhC+gabOsZ6d6ijlp2nfnKG47QMdoXTijv4=; b=hwUSZR6sB5SJnTU2BVnSLQfS/iOGBjQp07uCQ/QDT7e8n6pHCz3n6zJM6TE3A4KL0c WmYsP1e9JfqA7sTaFhYm48/3t4bQyGkVM+qeiAmVS0Sbsa7m/nE1WwoD0s+w9NTEng7d CqXP9GzzyMMNo/hO75zQ984Oa27z7KPRcLOJ+wsCDvkDtAuxIjeoxKznB0NiHRYLEBpj b16FlmwPTtDQO/Z3ifRnue5EbqepEmnhfq6g9sytMtqbhdzhLRcLe9UeTIXJCoFr2Ee/ 8TwuUHJRrWXVy5mJS/ZnuyUadsu1g9H/kunnIEMrHWxRWbt0gy3gjLR8hKY1Wyham7// mhOw== X-Gm-Message-State: AG10YOTq7NO/xiQRsDtC9aLY2hmebJkZlbtpjetLqVFznjJdkBA0SiDRGElE5Xvg2fTfuslM8eFkCd6IVf8E6Q== X-Received: by 10.107.14.73 with SMTP id 70mr26587622ioo.31.1454929049534; Mon, 08 Feb 2016 02:57:29 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 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:102657 On Mon, Feb 8, 2016 at 9:22 PM, wrote: >> Once you switch to Python 3 and Phoenix you have to modify this >> slightly, e.g. by adding this to the top of your code: >> >> try: >> basestring >> except: >> basestring = (bytes,str) >> > Everything else is 3 compatible so moving should be fairly painless > if/when phoenix becomes available. Small point: Even for code as small as this, I would be inclined to catch only the one exception you care about - in this case, NameError. I try to avoid having a bare except clause anywhere other than a "log and continue" or "react and reraise" kind of situation. ChrisA