mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
This commit is contained in:
parent
59ec315b04
commit
3de1e69dc7
1 changed files with 4 additions and 0 deletions
|
@ -1600,6 +1600,10 @@ variable. Space is saved because *__dict__* is not created for each instance.
|
||||||
|
|
||||||
Notes on using *__slots__*
|
Notes on using *__slots__*
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
* Without a *__dict__* variable, instances cannot be assigned new variables not
|
* Without a *__dict__* variable, instances cannot be assigned new variables not
|
||||||
listed in the *__slots__* definition. Attempts to assign to an unlisted
|
listed in the *__slots__* definition. Attempts to assign to an unlisted
|
||||||
variable name raises :exc:`AttributeError`. If dynamic assignment of new
|
variable name raises :exc:`AttributeError`. If dynamic assignment of new
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue