I'd rather have ``if ex.errno != errno.ENOENT:``. It's more descriptive to what happens. ``errno`` is available in the standard library.