There is a rule in Python programming called “it is Easier to Ask for Forgiveness than for Permission” (in short: EAFP) 1.

It means that you should catch exceptions instead of checking values for validity.


  1. http://stackoverflow.com/questions/8381193/python-handle-json-decode-error-when-nothing-returned ↩︎