Access input line on NameError?
mwh at python.net
Mon Dec 3 12:21:12 CET 2001
gb at cs.unc.edu writes:
> Can I get access to the offending text line of the input when I take a
> NameError exception? I see that it is available on a SyntaxError but I
> can't seem to find it on a NameError.
I think you can use the traceback module to do this. Or if you like
getting your hands dirty, use sys.exc_info() and grub around with
frame and code objects yourself.
One of the great skills in using any language is knowing what not
to use, what not to say. ... There's that simplicity thing again.
-- Ron Jeffries
More information about the Python-list