code: def wrap_object(func, before, after):
      '''
      before/after call will encapsulate callable object
      '''
      def _wrapper(*args, **kwargs):
          before()
          try:
              return func(*args, **kwargs)
          except Exception as e:
              raise e
          finally:
              after()
      return _wrappef wrap_object(func, before, after):
      '''
      before/after call will encapsulate callable object
      '''
      def _wrapper(*args, **kwargs):
          before()
          try:
              return func(*args, **kwargs)
          except Exception as e:
              raise e
          finally:
              after()
      return _wrapper
docs: before/after call will encapsulate callable object