Name of type of object
Jive Dadson
jdadson at yahoo.com
Wed Feb 9 16:57:15 EST 2005
More information about the Python-list mailing list
Wed Feb 9 16:57:15 EST 2005
- Previous message (by thread): Name of type of object
- Next message (by thread): Name of type of object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I don't think I've quite got it. The application I'm writing has some similarities to an interactive shell. Like an interactive shell, it executes arbitrary code that it receives from an input stream. When it gets an exception, it should create an informative message, regardless of the type of exception. The traceback routine does that, somehow, some way, but I've tried to read that code and figure out how and I don't get it. The best I have so far is, class Exec_thread(BG_thread): """ Execute a line of code in the global namespace. """ def _process(s): """ Process one instruction """ try: exec s.product in globals() except (Exception), e: handle_error( typename(e)+ ": " + str(e) ) But that works only if the exception happens to be derived from Exception. How do I handle the general case?
- Previous message (by thread): Name of type of object
- Next message (by thread): Name of type of object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list