I am a newbie at Python and trying to write a small program to put the exeception stack to a file. Could someone let me know why the below code is not printing the whole stack into the file. :
import logging
import traceback
def divlog(x,y):
try:
f = open("C:/files/divlog.txt", "a")
f.write("{0:g} / {1:g} = {2:g} \n".format(x, y , (x/y) ) )
except ZeroDivisionError:
#f.write("Error : \n" , traceback.format_exc())
raise
finally:
f.close()
divlog(100,21)
divlog(20,5)
divlog(10, 0)
divlog(100,spam)