I am learning OOP with Python and I am trying to figure how to get the accessor and mutator method for class level variables. I have no issues with instance level variables but I am having trouble with the class level ones.
from abc import ABC, abstractmethod
class Book(ABC):
#Class Variable
_libraryLoanDuration = 14
def __init__(self, bookName, yearPublished, cost):
self._title = title
self._yearPublished = yearPublished
self._cost = cost
#Accessor for class variable
@property
def libraryLoanDuration(cls):
return cls._libraryLoanDuration
#Mutator for class variable
@classmethod
def libraryLoanDuration(cls, newlibraryLoanDuration):
cls._libraryLoanDuration = newlibraryLoanDuration