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:
Harl
On Mar 23, 9:42 am, [EMAIL PROTECTED] wrote:
> On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Using the code below:
>
> > ---BEGIN CODE---
>
> > value = raw_input("Type a divisor: ")
> > try:
> >value = int(value)
> >print "42 / %d = %d" % (value, 42/value)
> > exc
On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> 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 in
[EMAIL PROTECTED] wrote:
> Make the last 'except' block like this:
>
> Except Exception, e:
> print e
while that's good enough for the given example, it's not good enough for
the general case (in contemporary Python, exceptions don't have to inherit
from the Exception class).
--
http://m
On Mar 23, 8:29 am, [EMAIL PROTECTED] wrote:
> On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Using the code below:
>
> > ---BEGIN CODE---
>
> > value = raw_input("Type a divisor: ")
> > try:
> >value = int(value)
> >print "42 / %d = %d" % (value, 42/value)
> > exc
Harlin Seritt wrote:
> In the last 'except' block, how can I print out the particular error
> name even though one is not specifically named?
the sys.exc_info() function returns information about the current exception.
see:
http://effbot.org/pyref/sys.exc_info
--
http://mail.python.or
On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> 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 in
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"
ex