Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save erikerlandson/f042fffde7e2aeb5f010e0254b873971 to your computer and use it in GitHub Desktop.
Save erikerlandson/f042fffde7e2aeb5f010e0254b873971 to your computer and use it in GitHub Desktop.
wrap a .ipy file in a big try/catch to catch any exception
$ echo "try:" > eje.ipy
$ awk '{print " ", $0}' < simple.ipy >> eje.ipy
$ cat >> eje.ipy <<- EOF
> except Exception as e:
> print("===========")
> print(e)
> print("===========")
> EOF
$ ~/conda/bin/ipython eje.ipy
45
time magic
CPU times: user 8 µs, sys: 1 µs, total: 9 µs
Wall time: 11 µs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment