classification
Title: Clarify __slots__ behaviour when inheriting
Type: feature request
Components: Documentation Versions: Python 2.7, Python 2.6, Python 2.5, Python 2.4, Python 2.3, Python 2.2.3, Python 2.2.2, Python 2.2.1, Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, strangefeatures
Priority: Keywords:

Created on 2008-07-09 07:22 by strangefeatures, last changed 2008-07-19 13:09 by georg.brandl.

Messages
msg69460 (view) Author: Andy (strangefeatures) Date: 2008-07-09 07:22
Suggest clarification on behaviour of the __slots__ attribute when
inheriting from classes that don't have __slots__ defined. Obviously the
superclass automatically creates __dict__, and it seems the subclass
inherits this. I presume this is expected behaviour, but I think it
would be worth clarifying in the 'Notes on using __slots__' section -
perhaps add something like:

"If you define __slots__ on a subclass when its superclass doesn't have
__slots__ defined, the superclass will automatically create a __dict__
instance which will be inherited by the subclass (as will other instance
attributes). Defining __slots__ on the subclass doesn't block this
inheritance."
msg70020 (view) Author: Georg Brandl (georg.brandl) Date: 2008-07-19 13:09
Added a note in r65136, thanks.
History
Date User Action Args
2008-07-19 13:09:52georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg70020
2008-07-09 07:22:58strangefeaturescreate