469,299 Members | 2,088 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

checking for ASCII character

Hi, is there a way to check if a letter entered is an uppercase ASCII
character?

Thanks

Daniel
Jul 18 '05 #1
5 12169
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

Jul 18 '05 #2
rm
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

Jul 18 '05 #3
Daniel wrote on Thu, 13 Nov 2003 19:59:12 -0000:
Hi, is there a way to check if a letter entered is an uppercase ASCII
character?


ascii_uppercase in the string module contains all uppercase ASCII chars.
Use "if ... in ..." to find out whether your letter is in that constant.

--
Yours,

Andrei

=====
Mail address in header catches spam. Real contact info (decode with rot13):
ce******@jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.
Jul 18 '05 #4
Greg Krohn:
If it needs to be ASCII, the simplest way is probably:

if ord(character) in range(65, 91):
<some code>


or

if character in string.ascii_uppercase:
...

Andrew
da***@dalkescientific.com
Jul 18 '05 #5
"Daniel" <da******@SPAMhalliwell1.plus.com> wrote in message news:<Qm******************@wards.force9.net>...
Hi, is there a way to check if a letter entered is an uppercase ASCII
character?


letter.isupper()
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by David Williams | last post: by
2 posts views Thread by Director - Minvent | last post: by
37 posts views Thread by chandy | last post: by
16 posts views Thread by akarui.tomodachi | last post: by
9 posts views Thread by simchajoy2000 | last post: by
6 posts views Thread by bruce | last post: by
6 posts views Thread by davetelling | last post: by
9 posts views Thread by =?Utf-8?B?UGhhbmlkaGFy?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.