Catching an unknown error

Harlin Seritt harlinseritt at yahoo.com
Fri Mar 23 09:48:20 EDT 2007


On Mar 23, 9:42 am, kyoso... at gmail.com wrote:
> On Mar 23, 8:16 am, "Harlin Seritt" <harlinser... at yahoo.com> wrote:
>
>
>
> > Using the code below:
>
> > ---BEGIN CODE---
>
> > value = raw_input("Type a divisor: ")
> > try:
> >    value = int(value)
> >    print "42 / %d = %d" % (value, 42/value)
> > except ValueError:
> >         print "I can't convert the value to an integer"
> > except ZeroDivisionError:
> >         print "Your value should not be zero"
> > except:
> >         print "Something unexpected happened"
>
> > ---END CODE---
>
> > In the last 'except' block, how can I print out the particular error
> > name even though one is not specifically named?
>
> > Thanks,
>
> > Harlin
>
> Thanks for pointing that out. I was following logic I was taught in
> Hetland's book, which supposedly was up-to-date for Python 2.4.
> Typical textbook error.
>
> Mike

Thanks guys... that gets 'er done.

Harlin Seritt




More information about the Python-list mailing list