Get A Class/instance Only Declared Attributes(not Inherited)?
I have 3 classes A,B,C , C inherting form A and B: class A: a = 'ala' class B: b = 'bla' class C(A,B): c = 'cla' How can I get only the Attributes of C, attrib
Solution 1:
You could access the __dict__
of C
directly via the vars
builtin.
>>>vars(C)['c']
'cla'
>>>vars(C)['b']...
KeyError: 'b'
There's not much more to say without further context about what your real problem is.
Post a Comment for "Get A Class/instance Only Declared Attributes(not Inherited)?"