Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50957
| Date | 2013-07-20 06:10 -0400 |
|---|---|
| From | Devyn Collier Johnson <devyncjohnson@gmail.com> |
| Subject | Re: Share Code Tips |
| References | (1 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4913.1374315056.3114.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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