Definition
Look before you leap. This coding style explicitly tests for
pre-conditions before making calls or lookups. This style contrasts with
the EAFP approach and is characterized by the presence of many
if statements.
In a multi-threaded environment, the LBYL approach can risk introducing a
race condition between “the looking” and “the leaping”. For example, the
code, if key in mapping: return mapping[key] can fail if another
thread removes key from mapping after the test, but before the lookup.
This issue can be solved with locks or by using the EAFP approach.