473,416 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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 12462
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: David Williams | last post by:
Hi all, i have been able to convert an ASCII character to an INT however im lost as to how to change them back. Cant find anything on the net (though im probably looking in the wrong places!)....
2
by: Director - Minvent | last post by:
Hi, I am reading from a serial port from a device which sends over an ascii character. It uses the full extended 256 character set and therefore has non-printing characters too. So what i want...
2
by: jau | last post by:
Hi co-listers! I have been off Python for 2 years and now, that i'm used to Eclipse and Java, I decided to start a project with Python to refresh skills this time using Eclipse and TrueStudio....
37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
16
by: akarui.tomodachi | last post by:
What is the most easiest way to convert an integer value to ASCII character format ? I tried with sprintf(). It works. Is there any other way to do that ? Objective:: I like to convert an...
9
by: simchajoy2000 | last post by:
Hi, I know what the ASCII Character Codes are for the 2nd and 3rd powers in VB.NET but I can't find the 6th power anywhere - does anyone know what it might be or if it even exists? Joy
6
by: bruce | last post by:
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii...
6
by: davetelling | last post by:
I am a total newbie, trying to slog through the Visual C# Express application. I need to be able to convert a single ASCII character (can be anything from 0 to 255) to an int for use in other...
9
by: =?Utf-8?B?UGhhbmlkaGFy?= | last post by:
Hi, I'm developing a Winform application in C#( .net 2.0). I've a dialog box where user can input text and that text would be sent across to other machine using sockets. When the user enters...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.