How to check properly that a variable value is an instance of any class?
For example:
class Foo:
pass
isinstance_of_any_class(isinstance) # Return False
isinstance_of_any_class(Foo) # Return False
isinstance_of_any_class(Foo()) # Return True
I have looked at:
isinstance- takes two mandatory arguments:objectandclassinfo- Determine if a variable is an instance of any class - question's author wanted to distinguish instances of builtin types from user-defined, but I want to distinguish instances from methods, function, classes an so on
- The
inspectmodule - doesn't haveisinstanceonly the following members that near needed:ismodule,isclass,ismethod,isfunction,isgeneratorfunction,isgenerator,iscoroutinefunction,iscoroutine,isawaitable,isasyncgen,istraceback,isframe,iscode,isbuiltin,isroutine,isabstract,ismethoddescriptor,isdatadescriptor,isgetsetdescriptor,ismemberdescriptor
The desired function could be implemented by negation of every other possible object type through inspect's members. How can I do it without enumerating all of inspect's members?