type(dict())
says "make a new dict, and then find out what its type is". It's quicker to say just dict
.
But if you want to just check type, a more idiomatic way is isinstance(x, dict)
.
Note, that isinstance
also includes subclasses (thanks Dustin):
class D(dict):
pass
d = D()
print("type(d) is dict", type(d) is dict) # -> False
print("isinstance (d, dict)", isinstance(d, dict)) # -> True