Easier to ask for forgiveness than permission

September 9, 2017

Exception handling in programming is a means to ensure our code handles exceptional circumstances, such as error conditions, gracefully, instead of dying in a horrible manner. However, computer programming is as much of an art as it is a skill, and over the years, people have come to use programming constructs in a highly effective way, albeit in a manner it was not originally intended to be used. The effectiveness of this innovative method of usage of a tool/construct/product often determines whether the technique becomes mainstream or not, and this is by no means restricted to the world of computer programming; for instance, it’s well known that Coke makes an excellent toilet and sink cleaner :)

In Python, exception handling is often used not just to check for failures, but also much more mundane things. I was reading about the usage of a series of try/excepts, in a daisy-chained manner (nested), and was trying to read up whether it was ‘Pythonic’ (a term which describes the likelihood of Python-purists to nod in agreement, or to rush to a sink to throw up, when they see your code). The original thread on Stackoverflow, is this: https://stackoverflow.com/questions/17015230/are-nested-try-except-blocks-in-python-a-good-programming-practice. Reading it, I got to hear about a very interesting expression; that expression is ‘Easier to ask for forgiveness than permission’ or EAFP, which is a bit of a contrasting style to ‘Look before you leap’ (LBYL).

I was intrigued about the origin of the expression which seemed to suggest a background far more aggressive than computer programming, and I wasn’t in the least surprised, when I found out that the person who coined the expression was US Navy Rear Admiral, and computer programmer, Grace Hopper, who is also credited with popularizing the term ‘bug’ in the field of computer programming. Reading about her, one realizes she was an incredible person, a pioneer in the true sense, someone who believed strongly and worked towards creation of machine-independent programming languages. This post is definitely in the category of #TodayILearned posts.