code: def attach(object, name):
      
      def decorator(func):
          setattr(object, name, func)
          return func
      return decorator
docs: Return a decorator doing ``setattr(object, name)`` with its argument.
  
      >>> spam = type('Spam', (object,), {})()
      >>> @attach(spam, 'eggs')
      ... def func():
      ...     pass
      >>> spam.eggs  # doctest: +ELLIPSIS
      <function func at 0x...>