Harlin> value = raw_input("Type a divisor: ") Harlin> try: Harlin> value = int(value) Harlin> print "42 / %d = %d" % (value, 42/value) Harlin> except ValueError: Harlin> print "I can't convert the value to an integer" Harlin> except ZeroDivisionError: Harlin> print "Your value should not be zero" Harlin> except: Harlin> print "Something unexpected happened"
Harlin> In the last 'except' block, how can I print out the particular Harlin> error name even though one is not specifically named? >>> try: ... 1/0 ... except Exception, err: ... print repr(err) ... <exceptions.ZeroDivisionError instance at 0x81e96ac> Skip -- http://mail.python.org/mailman/listinfo/python-list