#!/usr/bin/python def proof(): """ >>> proof() 4 """ l = (1,2,3) # here I defined the list, but it could be generated from something else # if it is complicated, I would like to debug it and print its value print l # this will raise and exception, and I will not be able to see why, because doctest won't print l return l[3] if __name__ == "__main__": import doctest doctest.testmod()