How can I iterate through the slots of a class, including those it inherits from parent classes?<br><br>class C(object):<br>  __slots__ = ['a']<br><br>class D(C):<br>  __slots__ = ['b']<br><br>>>> d = D()
<br>>>> d.__slots__<br>
['b']<br>
>>> d.a = 1 # this works, so slots inherit properly<br>>>> d.b = 2<br>>>> d.c = 3 # this doesnt work, like we expect<br>Traceback (most recent call last):<br>  File "<stdin>", line 1, in ?
<br>AttributeError: 'D' object has no attribute 'c'<br><br>The reason I want to do this is that I want to have the following, and let all the children inherit the parent's __init__:<br><br>class Parent(object):
<br>   __slots__ = ['whatever']<br>   def __init__(self, context=None, **kw):<br>     if context is None: context=getContext()<br>     for slot in SLOTITERATORHERE:<br>       # Resolve the slot's value, even for those things not specifically set in kw
<br><br>class Child1(Parent):<br>   __slots__ = ['for_me_only']<br><br>