title: Getting name of subclass from superclass?
body: <p>I have a base class <code>bc</code> and a number of subclasses based on <code>bc</code>.</p>
  
  <pre><code>class bc(Object):
    def get_subclass_name(self):
        # Retrieve the name of the most derived subclass of this instance
        pass
    def somemethod(self):
        x = self.get_subclass_name()
  
  class sc1(bc):
      pass
  
  class sc2(bc)
      pass
  </code></pre>
  
  <p>The idea is that when <code>somemethod()</code> is invoked on an instance of a subclass of <code>bc</code>, it will be able to use the name of the most derived subclass of that instance without needing to know in advance what potential subclasses may exist.</p>
  
  <p>I have put together a test case for this:</p>
  
  <pre><code>class base_class(object):
      @classmethod
      def get_subclass_name(cls):
          return cls.__name__
  
      def somemethod(self):
          print(base_class.get_subclass_name())
  
  class sub_class(base_class):
      pass
  
  sub_class().somemethod()
  </code></pre>
  
  <p>When this code is run it produces <code>base_class</code> rather than <code>sub_class</code>.</p>