How to determine if a variable is an instance in Python 3? I consider something to be an instance if it has __dict__
attribute.
Example:
is_instance_of_any_class(5) # should return False
is_instance_of_any_class([2, 3]) # should return Falseclass A:passa = A()
is_instance_of_any_class(a) # should return True
I have seen messages about using isinstance(x, type)
or inspect.isclass(x)
but this would give True for the class (A), not the instance.