If ones catches an exception outside of the function it is originally thrown, ones loses access to the local stack. As a result one cannot inspect the values of the variables th
ipython supports this (http://ipython.org). from inside ipython, do
%pdb on
and from then on, it will automatically drop you inside the debugger whenever you get an exception.
note that you'll (probably) quickly tire of this in general use... every time you mistype something and get a syntax error, you'll have to exit the debugger. but it's sometimes useful.