"Tuvas" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> I need a function that will tell if a given variable is a
> character or a number. Is there a way to do this? Thanks!
> 

If you really need to, you can test for type:
>>> for x in ['3',3,3.1,3j]:
...     print type(x)

<type 'str'>
<type 'int'>
<type 'float'>
<type 'complex'>
>>> for x in ['3',3,3.1,3j]:
...     if type(x) is str: print "it's a string"
...     elif type(x) is int: print "it's an int"
...     elif type(x) is float: print "it's a float"
...     elif type(x) is complex: print "it's a complex number"

it's a string
it's an int
it's a float
it's a complex number

-- 
rzed
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to