I read on many sites that if I want to create a read-only property, I should use the property
decorator.
Like this:
class MyClass(object):
def __init__(self):
self._a = None
@property
def a(self):
return self._a
I think this is a good solution if I have just 1-3 read-only properties in a class. But what if I have maybe 10 of these? This would result in 40 extra lines of code only to mark all of them as read-only. In my opinion this does not really fit to Python which is meant to be a language where you do not have to write a big bunch of code to do little things.
Is there really no shorter way to make a property read-only in Python?