Help with trapping an exception

Roger Binns rogerb at rogerbinns.com
Mon Aug 23 22:14:52 EDT 2004


pythos wrote:
> not defined, I easily figured out the problem.  But I need to use
> "try" and "except" to catch the exception, otherwise my program will
> end abruptly without finishing.  So how can I see the "NameError:
> global name 'Environment' is not defined" message in the "except"
> section of my code?  A call to sys.exc_info() doesn't show it.  Is
> there another function I can use?  Thanks.

I suggest using this code from the Python cookbook:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52215

I also strongly recommend getting the dead tree version as
well.  That recipe and many others are in it, and it is all
well laid out with lots of good discussion.

Roger 





More information about the Python-list mailing list