exception arg

Aahz Maruch aahz at netcom.com
Tue Jan 4 12:58:11 EST 2000


In article <slrn8749le.d0.mn at banger.iol.it>,
Mirko Nasato <mn at altern.org> wrote:
>
>>>> 1/0
>Traceback (innermost last):
>  File "<stdin>", line 1, in ?
>ZeroDivisionError: integer division or modulo
>>>> try:
>...     1/0
>... except ZeroDivisionError, arg:
>...     if arg == "integer division or modulo":
>...             print "This is what I expect."
>...     else:
>...             print 'Unexpected. "arg" is "%s".' % arg
>... 
>Unexpected. "arg" is "integer division or modulo".

Try plain

   print arg

or

  print type(arg)


Hint: you're getting confused by the %s forced string conversion.  After
you've done the previous two steps, try

   if str(arg) == "integer division or modulo":
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

The problem with an ever-changing .sig is that you have to keep changing it.



More information about the Python-list mailing list