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


Groups > comp.lang.python > #50956

Re: Share Code Tips

Date 2013-07-20 06:07 -0400
From Devyn Collier Johnson <devyncjohnson@gmail.com>
Subject Re: Share Code Tips
References <mailman.4868.1374241904.3114.python-list@python.org> <51e97e6e$0$29971$c3e8da3$5496439d@news.astraweb.com> <mailman.4885.1374271729.3114.python-list@python.org> <51ea016e$0$29971$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.4912.1374314863.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 07/19/2013 11:18 PM, Steven D'Aprano wrote:
> On Fri, 19 Jul 2013 18:08:43 -0400, Devyn Collier Johnson 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.
> As I showed, even for Latin letters, the trick of "if astring.lower() ==
> bstring.lower()" doesn't *quite* work, although it can be "close enough"
> for some purposes. For example, some languages treat accents as mere
> guides to pronunciation, so ö == o, while other languages treat them as
> completely different letters. Same with ligatures: in modern English, æ
> should be treated as equal to ae, but in Old English, Danish, Norwegian
> and Icelandic it is a distinct letter.
>
> Case-insensitive testing may be easier in many non-European languages,
> because they don't have cases.
>
> A full solution to the problem of localized string matching requires
> expert knowledge for each language, but a 90% solution is pretty simple:
>
> astring.casefold() == bstring.casefold()
>
> or before version 3.3, just use lowercase. It's not a perfect solution,
> but it works reasonably well if you don't care about full localization.
>
>
>
Thanks for the tips. I am learning a lot from this mailing list. I hope 
my code helped some people though.

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