Debugging.py 552 B

1234567891011121314151617181920
  1. ###############################################
  2. #
  3. # Odds and ends for debugging
  4. #
  5. ###############################################
  6. def print_call_chain(*args):
  7. import sys
  8. print(" ".join(map(str, args)))
  9. f = sys._getframe(1)
  10. while f:
  11. name = f.f_code.co_name
  12. s = f.f_locals.get('self', None)
  13. if s:
  14. c = getattr(s, "__class__", None)
  15. if c:
  16. name = "%s.%s" % (c.__name__, name)
  17. print("Called from: %s %s" % (name, f.f_lineno))
  18. f = f.f_back
  19. print("-" * 70)