code: def state(pre, post, attr='state'):
      
  
      def decorator(method):
          @six.wraps(method)
          def inner(self, *args, **kwargs):
              setattr(self, attr, pre)
              result = method(self, *args, **kwargs)
              setattr(self, attr, post)
              return result
          return inner
      return decorator
docs: State decorator