title: How to share variables between methods in a class?
body: <p>I'm looking for a way to make a variable set by one method/function in a class accessible by another method/function in that same class without having to do excess (and problematic code) outside.</p>
  <p>Here is an example that doesn't work, but may show you what I'm trying to do :</p>
  <pre><code>#I just coppied this one to have an init method
  class TestClass(object):
  
      def current(self, test):
          &quot;&quot;&quot;Just a method to get a value&quot;&quot;&quot;
          print(test)
          pass
  
      def next_one(self):
          &quot;&quot;&quot;Trying to get a value from the 'current' method&quot;&quot;&quot;
          new_val = self.current_player.test
          print(new_val)
          pass
  </code></pre>