Checking if a variable is a dictionary

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Mar 6 13:41:20 CET 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