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


Groups > comp.lang.python > #50929

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>
Date 2013-07-20 09:08 +1000
Subject Re: Share Code Tips
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4890.1374275325.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Jul 20, 2013 at 8:08 AM, Devyn Collier Johnson
<devyncjohnson@gmail.com> 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.

Case insensitivity is a *hard* problem. Don't fool yourself that you
can do it with a simple line of code and have it 'just work'. All
you'll have is something that works "most of the time", and then
breaks on certain input. As Steven said, using casefold() rather than
lower() will help, but that's still not perfect. The simplest and
safest way to solve Unicode capitalization issues is to declare that
your protocol is case sensitive. I have a brother who couldn't
understand why Unix file systems have to be case sensitive (why would
anyone ever want to have "readme" and "README" in the same directory,
after all?), until I explained how majorly hard it is with i18n, and
how it suddenly becomes extremely unsafe for your *file system* to get
this wrong.

ChrisA

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