title: why the class attr can not be used in this way?
body: <p>Why the class attr cannot be used in this way?</p>
  
  <pre class="lang-py prettyprint-override"><code>class A:
      a = 1
      d = [1, 2, 3, 4]
      e = [i for i in d if i == a]
      print(e)
  </code></pre>
  
  <p>and the error message is like this below:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/gavinc/code/eigen_clients/gavinc/a002.py", line 3, in &lt;module&gt;
      class A:
    File "/home/gavinc/code/eigen_clients/gavinc/a002.py", line 7, in A
      e = [i for i in d if i == a]
    File "/home/gavinc/code/eigen_clients/gavinc/a002.py", line 7, in &lt;listcomp&gt;
      e = [i for i in d if i == a]
  NameError: name 'a' is not defined
  </code></pre>
  
  <p>there will be no error if I write this out side of a class, something like the following code:</p>
  
  <pre class="lang-py prettyprint-override"><code>a1 = 1
  d1 = [1, 2, 3, 4]
  e1 = [i for i in d1 if i == a1]
  print(e1)
  </code></pre>