using try and except, what is wrong with this?
Bengt Richter
bokr at oz.net
Tue May 27 05:46:25 EDT 2003
On 27 May 2003 00:46:57 -0700, davidang at info.com.ph (David Ang) wrote:
>hello,
>
>this is exactly from your tutorial documentation, but my python
>interpreter is complaining...
>
>>>> def this_fail():
> x = 1/0
>
>>>> try:
> this_fail()
> except ZeroDivisionError, detail:
>
>IndentationError: unindent does not match any outer indentation level
>(line 3)
>
Did you forget to supply an idented line after the except line? E.g.,
>>> def this_fail():
... 1/0
...
>>> try:
... this_fail()
... except ZeroDivisionError, detail:
... print detail
...
integer division or modulo by zero
Seems to work. (A blank line interactively instead of " print detail" will trigger
interactive compile and execute, so it will complain about the missing line).
Regards,
Bengt Richter
More information about the Python-list
mailing list