How to detect what type a variable is?
Luis M. González
luismgz at gmail.com
Wed Nov 29 11:51:49 EST 2006
Leandro Ardissone 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
> not..
>
> Tried with:
> if type(artistList) == "<type 'list'>":
>
> and
> if type(artistList) == "list":
>
> but nothing..
You shouldn't enclose "list" inside quotes.
This is the correct way:
if type(artistList) == list:
do something...
or as someone suggested:
if isinstance(l, list):
do something...
hope this helps.
Luis
More information about the Python-list
mailing list