title: Initialize variable if class method is run
body: <p>I have a class, like</p>
  
  <pre><code>class D:
      def __init__(self):
          """some variables"""
      def foo(self):
          """generates lots of data"""
  </code></pre>
  
  <p>I would like to be able to store all of the data that <code>foo</code> creates within the instance of the class that <code>foo</code> is being called from. Almost like creating a new initialization variable, but only once the method is called. For if the user never calls <code>foo</code>, no need to have generated the data to begin with.</p>
  
  <p>Thanks! </p>