exceptions
Aleksei Guzev
aleksei.guzev at bigfoot.com
Thu Oct 5 13:01:22 EDT 2000
Why Python has exceptions of the only type? Take CLU. It supports exceptions
and signals. The difference is what happens upon completing an exception or
a signal handling code. In the latter case the execution returns to the next
statement after one wich throwed the signal. For instance one can encounter
zeros while dividing by elements of a list:
def f(divident):
L=[2,3,4,5,0,5,6,0,6,7]
for divisor in L:
print divident/divisor
f(100)
Assume I wish to print <Division by zero> in that cases, i.e. smth like
this:
def f(divident):
L=[2,4,5,0,5,0,8]
for divisor in L:
print divident/divisor
try:
f(100)
except ZeroDivision:
print <Division by zero>
should yield:
50
25
20
Division by zero
20
Division by zero
13
Maybe this should be done by another Python operator?
P.S. In FoxPro the execution may continue to the next statement after
handling block, or it may continue to the next statement to one which
throwed the exception, or it may repeat the <errorneous> statement after the
handling block.
More information about the Python-list
mailing list