title: Why method can't access class variable?
body: <p>I am trying to understand variable scopes in Python, most of the things are clear to me except for the part that I don't understand why class variable is not accessible from its method.<br>
  In following example <code>mydef1()</code> can't access <code>a</code>, but if <code>a</code> is declared in global scope(outside class definition) it can.</p>
  
  <pre><code>class MyClass1:
      a = 25
      def mydef1(self):
          print(a)
  ins1 = MyClass1()
  ins1.mydef1()
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Traceback (most recent call last):
    File "E:\dev\Python\scope_test2.py", line 6, in &lt;module&gt;
      ins1.mydef1()
    File "E:\dev\Python\scope_test2.py", line 4, in mydef1
      print(a)
  NameError: name 'a' is not defined
  </code></pre>