''' An example of exception handling in Python. Read through it carefully and figure out what it will do when run from the command line with 1 as its argument, ang again with 0 as argument. Pay special attention to which Entering/exiting messages get printed. Then try it. ''' import sys def A(x): print "Entering A with", x result = B(2*x) print "Exiting A with", result return result def B(x): print " Entering B with", x result = C(3*x) print " Exiting B with", result return result def C(x): print " Entering C with", x result = 1/x print " Exiting C with", result return result print "\nAnd (drum roll, please) the answer is..." answer = A(int(sys.argv[1])) print answer, "!\n"