Else and finally
Section: Exceptions
Else and finally
python
python
try:
result = risky()
except Exception as exc:
logger.error(exc)
else:
print(result)
finally:
cleanup()Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Exceptions