In the Python data model reference section on slots there is a list of notes on using __slots__. I am thoroughly confused by the 1st and 6th items, because they seem to be contradicting each other.
First item:
- When inheriting from a class without
__slots__, the__dict__attribute of that class will always be accessible, so a__slots__definition in the subclass is meaningless.
Sixth item:
- The action of a
__slots__declaration is limited to the class where it is defined. As a result, subclasses will have a__dict__unless they also define__slots__(which must only contain names of any additional slots).
It seems to me these items could be better worded or shown through code, but I have been trying to wrap my head around this and am still coming up confused. I do understand how __slots__ are supposed to be used, and I am trying to get a better grasp on how they work.
The Question:
Can someone please explain to me in plain language what the conditions are for inheritance of slots when subclassing?
(Simple code examples would be helpful but not necessary.)