Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50957

Re: Share Code Tips

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <devyncjohnson@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.028
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'languages.': 0.04; 'problem:': 0.07; 'python3': 0.07; 'collier': 0.09; 'url:unicode': 0.09; '8bit%:32': 0.16; 'comparisons,': 0.16; 'insensitive': 0.16; 'lowercase': 0.16; 'merely': 0.16; 'thankfully,': 0.16; 'url:faq': 0.16; 'wow,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'written': 0.21; 'code,': 0.22; 'rules': 0.22; 'separate': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'comparing': 0.24; 'subject:Code': 0.24; 'text.': 0.24; 'developers': 0.25; 'world,': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'character': 0.29; "doesn't": 0.30; 'work.': 0.31; 'code': 0.31; 'received:10.0.0': 0.31; "skip:' 10": 0.31; 'url:wiki': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'languages': 0.32; 'text': 0.33; 'fri,': 0.33; 'except': 0.35; 'something': 0.35; 'case,': 0.35; 'hundreds': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'received:10.0': 0.36; 'url:org': 0.36; 'example,': 0.37; 'received:10': 0.37; 'sometimes': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'is.': 0.60; 'most': 0.60; 'hope': 0.61; 'range': 0.61; "you're": 0.61; 'skip:n 10': 0.64; 'introduction': 0.68; 'family': 0.73; 'jul': 0.74; 'future,': 0.83; '11:44': 0.84; 'characters,': 0.84; 'dozens': 0.84; 'greek': 0.84; '2013': 0.98
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=w7RZ1+Uch7NKsUc9CzV5Y2i46DZ3amm3pR7WQkMHfAU=; b=AF1iNgq9COMGVtJJ6cU6lPguRGX/I4o36DqHlwoLRYY84VGNh6CCa6zQNi7pYZvVoC 1DnIuo6ugeIlV8i4oFOjCp2vaKF5KF3wzYM7xVwbJK2WteayviHWZifFcXTIrn4cf4WN cgC9k+X9sapgGJYWyD9EIbvXbsY6cT9RCU1a0BcGCAZxXoU8qtWoJf5K/Rtl9eza7BIw px3rDTWEML8uiNkMj/WX+/lTOtHOfzKdfFMQ6Ac+++RAiLyKPsOd6UUb6ZJstcvo6VQx IWiUwXTtihp+lApEpl2/XsrpIys6s+ZQ1TAFJM6zfkUkdBPOSCLGGFbKAlbyq17YiAyc a5Xw==
X-Received by 10.60.92.165 with SMTP id cn5mr20932763oeb.53.1374315053014; Sat, 20 Jul 2013 03:10:53 -0700 (PDT)
Date Sat, 20 Jul 2013 06:10:50 -0400
From Devyn Collier Johnson <devyncjohnson@gmail.com>
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 <python-list@python.org>
Subject Re: Share Code Tips
References <mailman.4868.1374241904.3114.python-list@python.org> <51e97e6e$0$29971$c3e8da3$5496439d@news.astraweb.com> <51E9B8EB.5060007@Gmail.com> <kscgv5$gv9$1@ger.gmane.org> <mailman.4894.1374282301.3114.python-list@python.org> <51ea07a4$0$29971$c3e8da3$5496439d@news.astraweb.com>
In-Reply-To <51ea07a4$0$29971$c3e8da3$5496439d@news.astraweb.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4913.1374315056.3114.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1374315056 news.xs4all.nl 15968 [2001:888:2000:d::a6]:59285
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50957

Show key headers only | View raw


On 07/19/2013 11:44 PM, Steven D'Aprano wrote:
> On Fri, 19 Jul 2013 21:04:55 -0400, Devyn Collier Johnson wrote:
>
>> 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.
> There are hundreds of written languages in the world, with thousands of
> characters, and most of them have rules about case-sensitivity and
> character normalization. For example, in Greek, lowercase Σ is σ except
> at the end of a word, when it is ς.
>
> ≻≻≻ 'Σσς'.upper()
> 'ΣΣΣ'
> ≻≻≻ 'Σσς'.lower()
> 'σσς'
> ≻≻≻ 'Σσς'.casefold()
> 'σσσ'
>
>
> So in this case, casefold() correctly solves the problem, provided you
> are comparing modern Greek text. But if you're comparing text in some
> other language which merely happens to use Greek letters, but doesn't
> have the same rules about letter sigma, then it will be inappropriate. So
> you cannot write a single "perfect" case-insensitive comparison, the best
> you can hope for is to write dozens or hundreds of separate case-
> insensitive comparisons, one for each language or family of languages.
>
> For an introduction to the problem:
>
> http://www.w3.org/International/wiki/Case_folding
>
> http://www.unicode.org/faq/casemap_charprop.html
>
>
>
>
>> Also, "ß" is not really the same as "ss".
> Sometimes it is. Sometimes it isn't.
>
>
>
Wow, my if-statement is so imperfect! Thankfully, only English people 
will talk to an English chatbot (I hope), so for my use of the code, it 
will work.
Do the main Python3 developers plan to do something about this?

Mahalo,
DCJ

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 09:51 -0400
  Re: Share Code Tips Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-19 17:59 +0000
    Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 18:08 -0400
      Re: Share Code Tips Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-20 03:18 +0000
        Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 06:07 -0400
    Re: Share Code Tips Chris Angelico <rosuav@gmail.com> - 2013-07-20 09:08 +1000
    Re: Share Code Tips Dave Angel <davea@davea.name> - 2013-07-19 19:09 -0400
    Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-19 21:04 -0400
      Re: Share Code Tips Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-20 03:44 +0000
        Re: Share Code Tips David Hutto <dwightdhutto@gmail.com> - 2013-07-20 00:15 -0400
        Re: Share Code Tips David Hutto <dwightdhutto@gmail.com> - 2013-07-20 00:22 -0400
        Re: Share Code Tips David Hutto <dwightdhutto@gmail.com> - 2013-07-20 00:26 -0400
        Re: Share Code Tips David Hutto <dwightdhutto@gmail.com> - 2013-07-20 00:27 -0400
        Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 06:10 -0400
        Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 08:36 -0400
    Re: Share Code Tips Chris Angelico <rosuav@gmail.com> - 2013-07-20 11:13 +1000
    Re: Share Code Tips Dave Angel <davea@davea.name> - 2013-07-19 21:51 -0400
    Re: Share Code Tips David Hutto <dwightdhutto@gmail.com> - 2013-07-19 23:42 -0400
    Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 06:06 -0400
    Re: Share Code Tips Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-20 08:20 -0400

csiph-web