title: Python3 - When exactly do you need to prepend "self._" to variable declarations within class methods?
body: <p>Sorry, this is a really basic question, but I am just wondering when it is necessary to prepend <code>self._</code> to variable declarations within methods? Every time I declare a variable within a method should I declare it with <code>self._</code> included? Is there any situation where I should not do this?</p>
  
  <p>Which of these methods would be valid for example (for some hypothetical class):</p>
  
  <pre><code>def thing_counter(self, thing):
      length_of_thing = len(thing)
      return length_of_thing
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>def thing_counter(self, thing):
      self._length_of_thing = len(thing)
      return self._length_of_thing
  </code></pre>
  
  <p>Both work, but which would be strictly correct? </p>
  
  <p>I know that a variable declaration is not really needed here, I am just trying to use a simple example.</p>
  
  <p>Cheers!</p>