Python, trace undefined variables
<p>in my program I have undefined variable somewhere:</p>

<pre><code>global name 'cmd' is not defined
</code></pre>

<p>How can I pull out the line number where the variable is being used?</p>

<p>I know where the error is (cmd versus self.cmd).  The question is how to get the line number (or why it isnt shown).</p>

<p>Since I was catching error, I had to <code>traceback.print_exc()</code> to get line numbers</p>
