title: returning another class when instantiating a class in python
body: <p>I am trying to use logging's <a href="http://docs.python.org/library/logging.handlers.html#memoryhandler" rel="nofollow" title="memory handler">memory handler</a> to buffer log messages to my actual logging handler. You use the memory handler by instantiating it with some arguments, like this:</p>
  
  <pre><code>import logging
  buffered_handler = logging.handlers.MemoryHandler(capacity=5,target=myActualHandler)
  </code></pre>
  
  <p>However, I don't want my application to have to instantiate a handler from logging directly, or pass any of the arguments; I'd like this code to look like this:</p>
  
  <pre><code>import myhandlers
  buffered_handler = myhandlers.BufferedRemoteHandler()
  </code></pre>
  
  <p>The question is: how do I do this? I'd like an attempt to instantiate my <code>BufferedRemoteHandler</code> to <em>actually</em> return logging's MemoryHandler with some specific arguments. I thought of just making <code>BufferedRemoteHandler</code> a function which returns the handler I want; is that the correct way? Is there a way to create a class which, when you instantiate it, actually returns a totally different class?</p>