def mutating_method(func):
 def wrapper(self, *__args, **__kwargs):
  old_mutable = self._mutable
  self._mutable = True
  try:
   return func(self, *__args, **__kwargs)
  finally:
   self._mutable = old_mutable
 return wrapper

def mutating_method ( func ) : def wrapper ( self , * __args , ** __kwargs ) : old_mutable = self . _mutable self . _mutable = True try : return func ( self , * __args , ** __kwargs ) finally : self . _mutable = old_mutable return wrapper
decorator for methods that are allowed to modify immutable objects .