Designate named attributes as read-only with the corresponding msg Method is additive. Making additional calls to this method will update existing messages and add to the current set of _read_only names.
(self, names, msg="Attribute is read-only")
| 94 | raise AttributeError(key) |
| 95 | |
| 96 | def set_read_only(self, names, msg="Attribute is read-only"): |
| 97 | """ |
| 98 | Designate named attributes as read-only with the corresponding msg |
| 99 | |
| 100 | Method is additive. Making additional calls to this method will update |
| 101 | existing messages and add to the current set of _read_only names. |
| 102 | """ |
| 103 | new_read_only = {name: msg for name in names} |
| 104 | if getattr(self, "_read_only", False): |
| 105 | self._read_only.update(new_read_only) |
| 106 | else: |
| 107 | object.__setattr__(self, "_read_only", new_read_only) |
| 108 | |
| 109 | def unset_read_only(self, keys): |
| 110 | if hasattr(self, "_read_only"): |