Problem: I have to check that the a returned value is a Python dictionary.
Q1. Which of these options is the proper way to do this?
type(x) == dict
type(x) == type(dict)
isinstance(d, dict)
Then there are the other variants using is
operator instead of ==
.
Q2. Many people say that checking the type of an object is generally a bad practice, but regarding to my initial problem, do I have any other choice?