Check out Python's built-in isintance
method, and also the type
method. To find out for the whole list, you could simply iterate through the list and output the resultant of the type
method.
For example:
for item in list:
print type(item)
Or if you are expecting certain types:
for item in list:
if isinstance(item,basestring):
print "I am a type of string!"
if isinstance(item,(str,unicode)):
print "I am a str or unicode!"
if isinstance(item,int):
print "I am a type of int!"
if isinstance(item,(int,float)):
print "I am an int or a float!"
if isinstance(item,bool):
print "I am a boolean!"
if isinstance(True,bool):
print "I am a boolean!"
if isinstance(True,int):
print "I am an int!" # because booleans inherit from integers ;)
The isinstance
method is usually better because it checks against inherited classes. See this post for a detailed discussion.