ProtectionΒΆ
The accretive.protection
subpackage offers variants on the main package
modules. The variants are classes with accretive attributes, ensuring that the
classes, themselves, for various kinds of accretive data structures are not
susceptible to accidental state change.
>>> from accretive.protection import Object
Let us illustrate this use case by defining a protected accretive object class.
>>> class MyProtectedObject( Object ):
... class_attr = 'Cannot be changed'
...
>>> MyProtectedObject.class_attr
'Cannot be changed'
Attempting to reassign the protected class attribute raises an error.
>>> MyProtectedObject.class_attr = 'New value'
Traceback (most recent call last):
...
accretive.exceptions.IndelibleAttributeError: Cannot reassign or delete existing attribute 'class_attr'.
Attempting to delete the protected class attribute also raises an error.
>>> del MyProtectedObject.class_attr
Traceback (most recent call last):
...
accretive.exceptions.IndelibleAttributeError: Cannot reassign or delete existing attribute 'class_attr'.