Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
""" FrozenClass and related. """
class FrozenException(Exception):
""" Is raised when a FrozenClass object is mutated. """
class FrozenClass(object):
""" Prevents mutation after initialisation.
Designed to be inherited from. """
_frozen = False
def __setattr__(self, name, value):
if self._frozen:
raise FrozenException("This object is immutable")
super().__setattr__(name, value)
def _freeze(self):
self._frozen = True