Is it possible to find out which, if any, variables are set in a class's __init__
method without instantiating the class and inspecting its __dict__
?
For example, if you load a module called mod
with some class called Class
, you can get the properties and methods of the class without creating an instance of it, using vars(mod.Class)
. If you create an instance of Class
, you can also find out which variables are set upon instantiation, by looking at mod.Class().__dict__
or using vars(mod.Class())
.
I'm wondering if you can get the class variables without instantiation. I'm trying to inspect the variables of an arbitrary class/type. It doesn't appear that the inspect
module provides such a function.