title: How to get the current Python class name in __init__ regardless of the class of "self"?
body: <p>I have a number of classes with code like this. Each <code>__init__</code> starts a thread and a logger with the name of the class. How do I get the name of the current class in its own definition, as a string, inside <code>__init__</code>? Note that <code>self</code> may not be an instance of the current class, so the following is not quite foolproof.</p>
  
  <pre><code>from threading import Thread
  import logging
  
  def myClassName(myclass):
      myclass._class_name = myclass.__name__
      return myclass
  
  @myClassName
  class SomeClass(object):
      def __init__(self):
          class_name = type(self)._class_name
          print "My class name in __init__ is", class_name
          self.thread = Thread(name=class_name)
          self.logger = logging.getLogger(class_name)
  </code></pre>
  
  <p>Update:</p>
  
  <p>To clarify:</p>
  
  <ul>
  <li>I want the name of the class being defined, not the class of the
  object passed in. </li>
  <li>I don't want to hard code the name of the class.</li>
  <li>I want to make it easy to copy/paste an example from one script to<br>
  another, and the fewer mentions of the unique class name, the better.
  (Inheritance isn't really efficient, as there are enough custom
  differences to make it awkward. But accidentally leaving in the name
  of the wrong class is a hard bug to find.)</li>
  </ul>