Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Catch all errors and and exceptions

NOTE: Generally speaking this isn't a great idea, but you can catch all errors with:

Code

try:
    with open('file-that-does-not-exit') as _file:
        print('will not make it here')
except Exception as e:
    print(e)
finally:
    print('and we are out')

The general reason to avoid it is that you can't tell what errors are happening and that might lead to unexpected things depending on what you put in the `except`