Feb-07-2020, 09:38 AM
You can use @property to define attributes that cannot be written. For example
class MyBorg: __shared = { '_alert_one': [], '_alert_two': [], } def __init__(self): self.__dict__ = self.__shared @property def alert_one(self): return self._alert_one @property def alert_two(self): return self._alert_two b = MyBorg() b.alert_one.append('spam') c = MyBorg() print(c.alert_one) # <--- prints ['spam'] # One cannot set the attribute # c.alert_one = 'bar' # raises AttributeError