I have a class Book, which has a property editable
, along with others:
class Book():
def __init__(self, name, ..., editable=True):
self.name = name
...
self.editable = editable
Book
has methods get_details()
, set_details()
and delete()
.
If editable
is set to False
, I want to raise an Exception in set_details()
and delete()
, stating that the Book is not editable.
I have gone through the Python docs but I haven't been able to find anything similar to a Not-Editable exception.
Is raising a custom exception the best way to do this, or can anyone suggest another workaround?
Thanks!