checking for ASCII character
rm
rm at rm.net
Thu Nov 13 16:00:49 EST 2003
Greg Krohn wrote:
> Daniel wrote:
>
>> Hi, is there a way to check if a letter entered is an uppercase ASCII
>> character?
>>
>> Thanks
>>
>> Daniel
>
>
> If you just want to know if a character is uppercase:
>
> if character.isupper():
> <some code>
>
> If it needs to be ASCII, the simplest way is probably:
>
> if ord(character) in range(65, 91):
> <some code>
>
>
>
> greg
>
one could check for ascii by doing:
try :
character.encode('ascii')
except UnicodeDecodeError :
ascii = False
else :
ascii = True
if ascii and character.isupper() :
pass
or something like it
bye,
rm
More information about the Python-list
mailing list