Overriding a built-in exception handler

callmebill at gmail.com callmebill at gmail.com
Thu Jul 21 10:39:10 EDT 2005


I'm having a tough time figuring this one out:


class MyKBInterrupt( ..... ):
   print "Are you sure you want to do that?"

if __name__ == "__main__":
       while 1:
           print "Still here..."


So this thing keeps printing "Still here..." until the user hits ctl-c,
at which time the exception is passed to MyKBInterrupt to handle the
exception, rather than to whatever the built-in handler would be.

I've Read-TFM, but I only see good info on how to create my own class
of exception;  I don't see anything on how to override an existing
exception handler.

Thanks in advance for any help.




More information about the Python-list mailing list