Checking if a variable is a dictionary

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Mar 6 07:41:20 EST 2008


Sam a écrit :
> Hello
> 
> if type(a) is dict:
>     print "a is a dictionnary!"


class MyDict(dict):
     pass

a = MyDict()

type(a) is dict
=> False




More information about the Python-list mailing list