Re: Is there any way to say ignore case with "in"?



Paul McGuire wrote:
On Apr 6, 8:53 am, "Martin v. Löwis" <mar...@xxxxxxxxxxx> wrote:
I know I could use:-
if lower(string1) in lower(string2):
<do something>
but it somehow feels there ought to be an easier (tidier?) way.
Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is
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?
[ ... ]
[i for i in range(65536) if unichr(i).lower().upper() !=
... unichr(i).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.
.



Relevant Pages

  • Re: So Has The Hulk Finally Killed Someone?
    ... If no one is ever in any danger, ... Stories are about character developments, ... Superhero comics are ... I'm a big believer in exceptions. ...
    (rec.arts.comics.marvel.universe)
  • Re: Combo box auto populate problem with CAPS
    ... character in upper case, inserted into the middle of the string of the found ... The choices in the combo box may be any combination: Upper case, ... find a correct match. ... Dirk Goldgar, MS Access MVP ...
    (microsoft.public.access.formscoding)
  • Re: Help needed [Logical operations in HLA/HYDE]
    ... The correct way to change upper to lower caseor lower to upper is best ... Then you talke the value of the character of say ta lower case symbol ... Here is the part I can show you of the ascii table used in ... Some langauges have accents on som of the the letters too! ...
    (comp.lang.asm.x86)
  • Re: Exercise 7-1
    ... Your indentation is inconsistent and doesn't correspond either to the ...     int c; ... to upper case if it's invoked as "upper", ... while loop to read each character from stdin, ...
    (comp.lang.c)
  • Re: WPF/LinqToSql/DataGrid
    ... Selecting certain rows of data from my WPF datagrid are generating exceptions that I'm not sure how to handle. ... String must be exactly one character long, but I can't tell what it is about these records that is causing the problem. ... The fix is to stop trying to squeeze multiple characters into a single ... concise-but-complete code sample that reliably demonstrates the problem. ...
    (microsoft.public.dotnet.languages.csharp)