Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.052 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'algorithm': 0.04; 'string.': 0.05; '"""': 0.07; 'collier': 0.09; 'converts': 0.09; 'tackle': 0.09; 'earlier.': 0.16; 'letters.': 0.16; 'lowercase': 0.16; 'perfect.': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'subject:Code': 0.24; 'unicode': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'code': 0.31; 'received:10.0.0': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'figure': 0.32; 'skip:c 30': 0.32; 'url:python': 0.33; "can't": 0.35; 'something': 0.35; 'german': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'described': 0.36; 'received:10.0': 0.36; 'similar': 0.36; 'url:org': 0.36; 'example,': 0.37; 'received:10': 0.37; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'remove': 0.60; 'dave': 0.60; 'most': 0.60; 'hope': 0.61; 'new': 0.61; 'url:3': 0.61; 'range': 0.61; 'simply': 0.61; 'making': 0.63; 'more': 0.64; 'future,': 0.83; '3.13': 0.84; 'angel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=9wYRtGQjTom+P/5zq1AAn1Sn4S5fdLUnzXqEmn4D2hU=; b=bMevctSnFCiCRvsf6kbafgMj0/zUmRfZlIJJkpytseCiuwMMGpigQhAEr/noCe83xs 5BtEm4bZSOzHHKYZViqi20EhEjq1FvJpXD85T0+RB/m6IcT986ypiyDtCWEZj7jLQple 1/BgHnSo0uTxEwb+pPTDTZXznWsIOG7WaRyRgF2SZn7dYZShbm1ZjoEiieoJzNzbKBd6 0HCq4/U+MAQn5G9Mb/YiDqF+sZkmCnY8LC9xDNLv2JHQD9ary/oVLm8dlSdrt8EBKd3H EAy1zcYwWuMFSWgX0VGY5+Fy1Ihc2pPsbZFG8MzlNnmNrLfxqu2vhlknsH3Z6pt1xW9d s2YQ== X-Received: by 10.43.91.73 with SMTP id bl9mr12543577icc.17.1374282297659; Fri, 19 Jul 2013 18:04:57 -0700 (PDT) Date: Fri, 19 Jul 2013 21:04:55 -0400 From: Devyn Collier Johnson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Python Mailing List Subject: Re: Share Code Tips References: <51e97e6e$0$29971$c3e8da3$5496439d@news.astraweb.com> <51E9B8EB.5060007@Gmail.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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374282301 news.xs4all.nl 15934 [2001:888:2000:d::a6]:35576 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:50936 On 07/19/2013 07:09 PM, Dave Angel wrote: > On 07/19/2013 06:08 PM, Devyn Collier Johnson wrote: >> >> On 07/19/2013 01:59 PM, Steven D'Aprano wrote: > > >> >> As for the case-insensitive if-statements, most code uses Latin letters. >> Making a case-insensitive-international if-statement would be >> interesting. I can tackle that later. For now, I only wanted to take >> care of Latin letters. I hope to figure something out for all >> characters. >> > > Once Steven gave you the answer, what's to figure out? You simply use > casefold() instead of lower(). The only constraint is it's 3.3 and > later, so you can't use it for anything earlier. > > http://docs.python.org/3.3/library/stdtypes.html#str.casefold > > """ > str.casefold() > Return a casefolded copy of the string. Casefolded strings may be used > for caseless matching. > > Casefolding is similar to lowercasing but more aggressive because it > is intended to remove all case distinctions in a string. For example, > the German lowercase letter 'ß' is equivalent to "ss". Since it is > already lowercase, lower() would do nothing to 'ß'; casefold() > converts it to "ss". > > The casefolding algorithm is described in section 3.13 of the Unicode > Standard. > > New in version 3.3. > """ > Chris Angelico said that casefold is not perfect. In the future, I want to make the perfect international-case-insensitive if-statement. For now, my code only supports a limited range of characters. Even with casefold, I will have some issues as Chris Angelico mentioned. Also, "ß" is not really the same as "ss". Mahalo, DCJ