This question evaluates proficiency in Python object-oriented programming, specifically correct use of @property, @classmethod, and @staticmethod, safe handling of mutable defaults and encapsulation of internal state, and design decisions around equality and hashing.
You are working with a simple class hierarchy where Director extends Cast. Implement a robust, testable Python solution that uses @property, @classmethod, and @staticmethod correctly, and avoids common pitfalls such as mutable defaults and leaking internal mutable state.
Starting point:
class Cast:
def __init__(self, actors: list[str]):
self.actors = list(actors)
class Director(Cast):
def __init__(self, name: str, actors: list[str], movies: list[str]):
super().__init__(actors)
self.name = name
self.movies = list(movies)
self._awards: list[tuple[str,int]] = [] # (award_name, year)
Login required