Coding with EAFP mindset in python

EAFP principle (Easier to Ask for Forgiveness than it is to get Permission)

The EAFP is a common principle/coding style used by the python community. It is a style in which the attributes or keys are assumed to be present and if the assumption is false, it is catched and handled in an exception. try/except play a great role in this style. This is opposed to LBYL style(Look Before You Leap) where the programmer needs to carefully evaluate the conditions before doing something.

More …