title: Accessing class variables from a list comprehension in the class definition
body: <p>How do you access other class variables from a list comprehension within the class definition?  The following works in Python 2 but fails in Python 3:</p>
  
  <pre><code>class Foo:
      x = 5
      y = [x for i in range(1)]
  </code></pre>
  
  <p>Python 3.2 gives the error:</p>
  
  <pre><code>NameError: global name 'x' is not defined
  </code></pre>
  
  <p>Trying <code>Foo.x</code> doesn't work either.  Any ideas on how to do this in Python 3?</p>
  
  <p>A slightly more complicated motivating example:</p>
  
  <pre><code>from collections import namedtuple
  class StateDatabase:
      State = namedtuple('State', ['name', 'capital'])
      db = [State(*args) for args in [
          ['Alabama', 'Montgomery'],
          ['Alaska', 'Juneau'],
          # ...
      ]]
  </code></pre>
  
  <p>In this example, <code>apply()</code> would have been a decent workaround, but it is sadly removed from Python 3.</p>