In a Python program I have a read-only property that I create using
bla = property(fget=_get_bla)
where _get_bla is a method defined in the class. When a program tries to write in this property
obj.bla = 1
I obviously get:
AttributeError: can’t set attribute
Is there a way to customize this exception? For example, I would like to change the message to
‘bla’ is a read-only property of class X
Thanks,
Yes, you can add next method to your class:
and