Exceptions: Difference between revisions

Content added Content deleted
No edit summary
Line 1: Line 1:
{{task}}
==[[Python]]==
[[Category:Python]]

===try-except-finally-else===

'''Interpreter''': Python 2.5

Before Python 2.5 it was not possible to use finally and except together.

try:
foo()
except TypeError:
bar()
finally:
baz()
else:
# no exception occurred
quux()


==[[C plus plus|C++]]==
==[[C plus plus|C++]]==
[[Category:C plus plus]]


C++ has no finally construct. Instead you can do this in the
C++ has no finally construct. Instead you can do this in the
Line 50: Line 34:
}
}
}
}

==[[Python]]==
[[Category:Python]]

===try-except-finally-else===

'''Interpreter''': Python 2.5

Before Python 2.5 it was not possible to use finally and except together.

try:
foo()
except TypeError:
bar()
finally:
baz()
else:
# no exception occurred
quux()