title: Python set docstring and get method name of dynamically generated classmethod
body: <p>I'm trying to get/set the name and docstring of dynamically created class methods as follows, but am having trouble figuring out exactly how to do it:</p>
  
  <pre><code>import sys
  import inspect
  
  class test(object):
      pass
  
  @classmethod
  def genericFunc(cls, **kwargs):
      print "function:", (inspect.stack()[0][3])
      print "kwargs:", kwargs
  
  function_list = ['myF1', 'myF2']
  for func in function_list:
      setattr(test, func, genericFunc)
      #set docstring for func here?
  
  if __name__ == '__main__':
      x = test()
      print "docstring:", x.myF1.__doc__
      x.myF1(arg1="foo")
      y = test()
      print "docstring:", y.myF2.__doc__
      y.myF2(arg1="foo", arg2="bar")
      sys.exit()
  </code></pre>
  
  <p>Currently the output is:</p>
  
  <pre><code>docstring: None
  function: genericFunc
  kwargs: {'arg1': 'foo'}
  docstring: None
  function: genericFunc
  kwargs: {'arg1': 'foo', 'arg2': 'bar'}
  </code></pre>
  
  <p>What I'd like to have is:</p>
  
  <pre><code>docstring: description of myF1
  function: myF1
  kwargs: {'arg1': 'foo'}
  docstring: description of myF2
  function: myF2
  kwargs: {'arg1': 'foo', 'arg2': 'bar'}
  </code></pre>
  
  <p>In the for loop I tried doing <code>setattr(test.func, "__doc__", "description of %s" % func)</code>, which resulted in an AttributeError exception (type object 'test' has no attribute 'func'), and if I hard-code 'test.myF1' instead of 'test.func' I get an AttributeError for attribute <code>'__doc__'</code> of 'instancemethod' not being writable.</p>
  
  <p>Finally, the inspect.stack() returns "genericFunc" instead of a dynamic function name ('myF1' or 'myF2'), is it possible to get/set the latter so that I can check the value of the method's <code>__name__</code> within genericFunc to perform certain actions depending on its value?</p>