title: Proxy object for lazy initialization
body: <p>Are there any ready-to-use Python module that provides an easy to use proxy object that only initializes the "real" object when really needed?</p>
  
  <p>Ideally I'm looking for a transparent implementation so that code dealing with this proxy object does not need to be aware that it is not the actual object.</p>
  
  <p>I want to use it like this:</p>
  
  <pre><code>class Example:
      def __init__(self):
          print("Example initialized")
  
  lazy = Proxy(Example)
  print(isinstance(lazy, Example))
  # Example initialized
  # True
  </code></pre>
  
  <p>As you can see it would behave very much like a unittest.MagicMock.</p>
  
  <p>If there aren't any libs offering functionality like this out there I'll implement it myself but I want to be sure no one else have done this yet.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I expect this proxy object to follow a through implementation <a href="http://code.activestate.com/recipes/496741-object-proxying/" rel="nofollow noreferrer">like this</a>.</p>