title: Initializing a Subclass Instance from a Superclass Object
body: <p>The documentation for <a href="https://docs.python.org/2/library/logging.html#logger-objects" rel="nofollow"><code>logging.Logger</code></a> states:</p>
  
  <blockquote>
    <p>Note that Loggers are never instantiated directly, but always through the module-level function logging.getLogger(name)</p>
  </blockquote>
  
  <p>This leads me to the following question (for which I'll switch to some <code>Foo</code> class instead of <code>logging.Logger</code>, since I'd like to ask about the principle in general).</p>
  
  <hr>
  
  <p>Suppose there's some class <code>Foo</code>, with several attributes and methods:</p>
  
  <pre><code>class Foo:
      def method_0(self..):
          ...
  
      def method_1(self..):
          ...
  
      def method_n(self..):
          ...
  </code></pre>
  
  <p>I'd like to subclass <code>Foo</code>, and specialize only a couple of these methods. </p>
  
  <pre><code>class SubFoo(Foo):
      def method_1(self, ...):
          ...
          # Or super - not the point of the question.
          Foo.method_1(self, ...)
  
      ...
  </code></pre>
  
  <p>The problem is that <code>Foo</code> doesn't have a constructor available, only the means to create an object of type <code>Foo</code>, say via <code>getFoo</code>. The "<code>Foo</code>" part of <code>SubFoo</code> needs to be an "approved" <code>Foo</code> object, and I don't know how to force <code>SubFoo</code>s <code>Foo</code> part to be made the "approved" object.</p>
  
  <p><strong>Note</strong></p>
  
  <p>There are obviously several <em>workarounds</em> to subclassing <code>Foo</code>, e.g., composition, monkey-patching, clever games with <code>__dict__</code>/<code>gettatr</code>, etc. Notwithstanding, this question is about subclassing.</p>