You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
552 B

4 years ago
  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)