How would you define a class attribute that should not be overridden by subclasses?
- Declare it as a constant
- Declare it as a static method
- Prefix it with an underscore (_)
- Use the @final decorator
To define a class attribute that should not be overridden by subclasses, prefix it with an underscore (_). While Python doesn't enforce strict encapsulation, this convention signals to other programmers that the attribute should not be modified.
Loading...
Related Quiz
- You are asked to create a plot comparing the distribution of a variable across different categories, highlighting the median and interquartile range. Which Seaborn plot would you choose?
- The _______ file can be used to execute initialization code for a package.
- How would you handle missing data for a numerical feature in a dataset before training a machine learning model?
- How would you remove duplicate values from a list in Python?
- While iterating through data entries, you want to avoid processing entries labeled as 'SKIP.' Instead of terminating the loop upon encountering such entries, what should you use to continue to the next entry?