IsString

Gary Herron gherron at islandtraining.com
Mon Dec 12 11:51:52 EST 2005


Tuvas wrote:

>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!
>
>  
>
In Python, all values have an associated type which you can query with 
type(v) thus:

  from types import *

  if type(v) == IntType:
      ... whatever ...

Several types would qualify as "numbers":  IntType, FloatType, LongType, 
and ComplexType,
and several as "strings":  StringType and UnicodeType

Gary Herron




More information about the Python-list mailing list