How to find the type ...

Steven Bethard steven.bethard at gmail.com
Fri Dec 9 12:16:49 EST 2005


Lad wrote:
> How can I find out in Python whether the operand is integer or a
> character and change from char to int ?

Python doesn't have a separate character type, but if you want to 
convert a one-character string to it's ASCII number, you can use ord():

 >>> ord('A'), ord('z')
(65, 122)

The answer to your first question is that you probably don't want to. 
You probably want two separate functions, one that takes an integer and 
one that takes a character.  What's your actual function look like?

STeVe



More information about the Python-list mailing list