title: How to access dictionary value from class variable while creating a new dictionary
body: <p>This seems like a really weird scoping issue:</p>
  
  <p>First I'll show what works:</p>
  
  <pre><code>class A():
     x = 1
     y = x
  
  class B():
     x = {'a' : 1, 'b' : 2}
     y = {z : 1 for z in x}
  </code></pre>
  
  <p>Does not work:</p>
  
  <pre><code>class C():
     x = {'a' : 1, 'b' : 2}
     y = {z : max(x) for z in x}    #  max could be replaced with any function
  </code></pre>
  
  <p>Leading to:</p>
  
  <pre><code>NameError: name 'x' is not defined
  </code></pre>
  
  <p>And I know it refers to the "inner" (value) in the dictionary comprehension. </p>
  
  <p>This probably means that somehow in the list comprehension the class scope is not available. </p>
  
  <p>How come, and how can we work around this (without using it as an instance variable, i.e. using __init__)?</p>