title: When is it preferable to pass variables to methods vs. read attributes in python
body: <p>When working within a class, I often chain calculations together, passing results from one method to another.</p>
  <p>I have used two ways of doing this: Option 1, store the variables as attributes, then read those attributes in the next method; or Option 2, explicitly return and pass variables between methods.</p>
  <p><strong>Option 1, storing results as attributes</strong></p>
  <pre><code>class MyClass:
      def method1(self):
          ... code that generates result1 and result2 ...
          self.result1 = result1
          self.result2 = result2
      def method2(self):
          ... code that generates result3 using result1 and result2 ...
          self.result3 = result3
  </code></pre>
  <p><strong>Option 2, returning and explicitly passing in variables</strong></p>
  <pre><code>class MyClass:
      def method1(self):
          ... code that generates result1 and result2 ...
          return result1, result2
      def method2(self, result1, result2):
          ... code that generates result3 using result1 and result2 ...
          return result3
  </code></pre>
  <p>Option 1 has the problem where it's unclear 'method2' requires 'result1' and 'result2'. If we forget that we need to run 'method1', we could get confusing errors.</p>
  <p>Option 2 solves this, as we clearly need 'result1' and 'result2' for 'method2'. However it feels a little messy, especially if the method requires a large number of inputs. It also feels like it defeats the point of having access to the all attributes of our class.</p>
  <p>I've seen both used so maybe it's a matter of preference, but I wonder if there are any guidelines people have had success with. Specifically:</p>
  <ul>
  <li>Are there any situations where one is preferred over the other?</li>
  <li>Are there any &quot;rules of thumb&quot; for which variables get passed and which get stored?</li>
  </ul>