How to detect what type a variable is?
Roberto Bonvallet
Roberto.Bonvallet at cern.ch
Wed Nov 29 11:29:42 EST 2006
Leandro Ardissone wrote:
> 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..
type() doesn't return a string, it returns a type object.
You should try this:
if isinstance(artistList, list):
...
Cheers,
--
Roberto Bonvallet
More information about the Python-list
mailing list