Python Programming - Inheritance - Discussion

Discussion Forum : Inheritance - General Questions (Q.No. 23)
23.
What is the purpose of the __slots__ attribute in a Python class?
To define class attributes
To create a new instance of the class
To restrict the attributes that can be dynamically added to instances
To access superclass attributes directly
Answer: Option
Explanation:
The __slots__ attribute restricts the attributes that can be dynamically added to instances, improving memory efficiency.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.