python programmers tend to follow model of ask forgiveness rather than permissionwhich is to saythey execute code and then deal with anything that goes wrong the alternativeto look before you leapis generally frowned upon there are few reasons for thisbut the main one is that it shouldn' be necessary to burn cpu cycles looking for an unusual situation that is not going to arise in the normal path through the code thereforeit is wise to use exceptions for exceptional circumstanceseven if those circumstances are only little bit exceptional taking this argument furtherwe can actually see that the exception syntax is also effective for flow control like an if statementexceptions can be used for decision makingbranchingand message passing imagine an inventory application for company that sells widgets and gadgets when customer makes purchasethe item can either be availablein which case the item is removed from inventory and the number of items left is returnedor it might be out of stock nowbeing out of stock is perfectly normal thing to happen in an inventory application it is certainly not an exceptional circumstance but what do we return if it' out of stocka string saying out of stocka negative numberin both casesthe calling method would have to check whether the return value is positive integer or something elseto determine if it is out of stock that seems bit messy insteadwe can raise outofstockexception and use the try statement to direct program flow control make sensein additionwe want to make sure we don' sell the same item to two different customersor sell an item that isn' in stock yet one way to facilitate this is to lock each type of item to ensure only one person can update it at time the user must lock the itemmanipulate the item (purchaseadd stockcount items left )and then unlock the item here' an incomplete inventory example with docstrings that describes what some of the methods should doclass inventorydef lock(selfitem_type)'''select the type of item that is going to be manipulated this method will lock the item so nobody else can manipulate the inventory until it' returned this prevents selling the same item to two different customers ''pass def unlock(selfitem_type)'''release the given type so that other customers can access it ''pass def purchase(selfitem_type)