title: Python scope inside a nested function inside a class?
body: <p>How can I set a class variable from inside a function inside another function?</p>
  
  <p>var.py</p>
  
  <pre><code>class A:
      def __init__(self):
          self.a = 1
          self.b = 2
          self.c = 3
      def seta(self):
          def afunction():
              self.a = 4
          afunction()
      def geta(self):
          return self.a
  </code></pre>
  
  <p>run.py</p>
  
  <pre><code>cA = A()
  print cA.a
  cA.seta()
  print cA.a
  print cA.geta()
  </code></pre>
  
  <p>python run.py</p>
  
  <pre><code>1
  1
  1
  </code></pre>
  
  <p>why does a not equal 4 and how can I make it equal 4?</p>
  
  <p>Edit:</p>
  
  <p>Thanks everyone - sorry, I just saw now. I accidentally was off by a _ in one of my names.... so my scope is actually all ok.</p>