List/Set/Dict..

John Machin sjmachin at lexicon.net
Thu Jan 15 06:18:21 EST 2009


On Jan 14, 1:53 pm, "bruce" <bedoug... at earthlink.net> wrote:
> Hi...
>
> i have the test dict/list
>  a= {"a": 'a1',"b" : "b1"}
>  b= [{"a": 'a1',"b" : "b1"}]
>
> i'm trying to figure out how to programtically tell them apart...
>
> ie, which is a dict, and which is a list...

>>> a = {"a": 'a1', "b": "b1"}
>>> b = [{"a": 'a1', "b": "b1"}]
>>> isinstance(a, list)
False
>>> isinstance(b, list)
True
>>> isinstance(a, dict)
True
>>> isinstance(b, dict)
False
>>> type(a)
<type 'dict'>
>>> type(b)
<type 'list'>
>>>



More information about the Python-list mailing list