How to detect what type a variable is?

Daniel Klein danielkleinad at
Wed Nov 29 17:37:23 CET 2006

On 29 Nov 2006 08:25:35 -0800, "Leandro Ardissone"
<lardissone at> wrote:

>great, thanks
>And how I can compare this "<type 'str'>" output ?
>I want to decide what to do if the var is an string and what to do if
>Tried with:
>if type(artistList) == "<type 'list'>":
>if type(artistList) == "list":
>but nothing..

Try it this way...

>>> artistList = []
>>> isinstance(artistList, list)
>>> if isinstance(artistList, list):
	print "I'm a list."

I'm a list.

Daniel Klein

More information about the Python-list mailing list