Cloak Immutable Modifier¶
Class implementations¶
-
class
cloak.immutable.Immutable[source]¶ Bases:
objectAny class inheriting from ImmutableSlotted will not allow modification of instance attributes after the initialization of the object is completed (i.e. the __init__ call completes).
This class provides shallow immutability (immutability of the child attributes is not enforced), much like a tuple object would. This class does not inherit from tuple, however, so that the occasionally awkward/incorrect iterator and element access behaviors are not inherited (though in general, inheriting from tuple is another valid approach to shallow immutability).
The difference between this and Immutable is that the _locked attribute is specified in the __slots__ definition, thus this will work correctly with child classes that specify __slots__.
-
class
cloak.immutable.ImmutableSlotted[source]¶ Bases:
objectAny class inheriting from ImmutableSlotted will not allow modification of instance attributes after the initialization of the object is completed (i.e. the __init__ call completes).
This class provides shallow immutability (immutability of the child attributes is not enforced), much like a tuple object would. This class does not inherit from tuple, however, so that the occasionally awkward/incorrect iterator and element access behaviors are not inherited (though in general, inheriting from tuple is another valid approach to shallow immutability).
The difference between this and Immutable is that the _locked attribute is specified in the __slots__ definition, thus this will work correctly with child classes that specify __slots__.