Global Name 'q' not Defined - Python
<p>I have a program like :</p>

<pre><code>class ABC:

    q = {}

    def update:
        self.state = (xx,xx)
        global q
        if self.state in q:
            // do something
</code></pre>

<p>I am getting the error :</p>

<blockquote>
  <p>"NameError: global name 'q' is not defined"</p>
</blockquote>

<p>Im new to python and need some help.</p>

<p><code>q</code> isn't being declared as a global variable here - it's being declared as a class variable of class <code>ABC</code>.</p>

<p>If you want <code>q</code> to be global, you should define it before you start declaring the class.</p>

python nameerror