a -very- case sensitive search

Dustan DustanGroups at gmail.com
Sat Nov 25 18:09:51 EST 2006


Steven D'Aprano wrote:
> On Sat, 25 Nov 2006 13:39:55 -0800, Ola K wrote:
>
> > Hi,
> > I am pretty new to Python and I want to make a script that will search
> > for the following options:
> > 1) words made of uppercase characters -only- (like "YES")
> > 2) words made of lowercase character -only- (like "yes")
> > 3) and words with only the first letter capitalized (like "Yes")
> > * and I need to do all these considering the fact that not all letters
> > are indeed English letters.
> >
> > I went through different documention section but couldn't find a right
> > condition, function or method for it.
>
> At the command prompt:
>
>
> >>> dir('')
> # result edited for clarity
> [ ... 'isalnum', 'isalpha', 'isdigit', 'islower',
> 'isspace', 'istitle', 'isupper',  ... ]
>
> Then do this:
>
> >>> help(''.islower)
>
> and read the text it provides. Then experiment on the command line:
>
> >>> 'abcd1234'.islower()
> True
> >>> 'aBcd1234'.islower()
> False

Forget what I said; I didn't know about the str.is* methods.

> Then come back to us if they aren't suitable, and tell us WHY they aren't
> suitable.
> 
> 
> -- 
> Steven.




More information about the Python-list mailing list