Re: Is there any way to say ignore case with "in"?
- From: Mel <mwilson@xxxxxxxxxxxx>
- Date: Mon, 07 Apr 2008 08:55:19 -0400
Paul McGuire wrote:
On Apr 6, 8:53 am, "Martin v. Löwis" <mar...@xxxxxxxxxxx> wrote:[ ... ]Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() isI know I could use:-
if lower(string1) in lower(string2):
<do something>
but it somehow feels there ought to be an easier (tidier?) way.
the same character, as the character is already in lower case.
It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG
is gone - there is no upper-case version of a "long s".
It's .upper().lower() is U+0073, LATIN SMALL LETTER S.
So should case-insensitive matching match the small s with the small
long s, as they have the same upper-case letter?
... unichr(i).upper()][i for i in range(65536) if unichr(i).lower().upper() !=
[304, 1012, 8486, 8490, 8491]
Instead of 15 exceptions to the rule, conversion to upper has only 5
exceptions. So perhaps comparsion of upper's is, while not foolproof,
less likely to encounter these exceptions? Or at least, simpler to
code explicit tests.
I don't know what meaning is carried by all those differences in lower-case glyphs. Converting to upper seems to fold together a lot of variant pi's and rho's which I think would be roughly a good thing.
I seem to recall that the tiny iota (ypogegrammeni) has or had grammatical significance. The other effect would be conflating physics' Angstron unit and Kelvin unit signs with ring-a and K. Applicaton programmers beware.
Mel.
.
- References:
- Is there any way to say ignore case with "in"?
- From: tinnews
- Re: Is there any way to say ignore case with "in"?
- From: 7stud
- Re: Is there any way to say ignore case with "in"?
- From: "Martin v. Löwis"
- Re: Is there any way to say ignore case with "in"?
- From: Paul McGuire
- Is there any way to say ignore case with "in"?
- Prev by Date: Re: Wxpython. Is it possible to change layout in a running application? Selfmade listbox
- Next by Date: Re: Presumably an import is no faster or slower than opening a file?
- Previous by thread: Re: Is there any way to say ignore case with "in"?
- Next by thread: having list attribute to track max size
- Index(es):
Relevant Pages
|