parameters: (decorator)
return_statement: return _dec
docstring: Converts a function decorator into a method decorator
docstring_summary: Converts a function decorator into a method decorator
docstring_tokens: Converts a function decorator into a method decorator
function: def method_decorator(decorator):
      """
      Converts a function decorator into a method decorator
      """
      def _dec(func):
          def _wrapper(self, *args, **kwargs):
              def bound_func(*args2, **kwargs2):
                  return func(self, *args2, **kwargs2)
              # bound_func has the signature that 'decorator' expects i.e.  no
              # 'self' argument, but it is a closure over self so it can call
              # 'func' correctly.
              return decorator(bound_func)(*args, **kwargs)
          return wraps(func)(_wrapper)
      update_wrapper(_dec, decorator)
      # Change the name to aid debugging.
      _dec.__name__ = 'method_decorator(%s)' % decorator.__name__
      return _dec
function_tokens: def method_decorator ( decorator ) : def _dec ( func ) : def _wrapper ( self , * args , * * kwargs ) : def bound_func ( * args2 , * * kwargs2 ) : return func ( self , * args2 , * * kwargs2 ) # bound_func has the signature that 'decorator' expects i.e.  no # 'self' argument, but it is a closure over self so it can call # 'func' correctly. return decorator ( bound_func ) ( * args , * * kwargs ) return wraps ( func ) ( _wrapper ) update_wrapper ( _dec , decorator ) # Change the name to aid debugging. _dec . __name__ = 'method_decorator(%s)' % decorator . __name__ return _dec