I am working in Python so attribute privacy isn’t enforced. I have a
Library class that stores a list of library
Items related to that library. I want to be able to access the library Items through the Library class. Right now I accomplish that by returning the “private” items attribute. However, any class would then be able to modify that list. Would I need to make a “deep copy” of these in order for the
items attribiute to be truly private? Should I just make the attribute public?
class Library(): def __init__(self, name) -> None: self._hours = () self._items = () self._name = name def get_hours_str(self): ret = "" for day in self._hours: ret += day + 'n' return ret def get_items(self): return self._items