import traceback
traceback.print_stack()
print traceback.format_exc()

(Known as the stacktrace in a previous life)