{
  "id": "python-traceback-table",
  "kind": "table",
  "slug": "python-traceback",
  "iil_id": null,
  "note_url": "https://iinventedlight.com/library/notes/python-traceback/",
  "title": "Python traceback - print or capture exception stack traces as strings",
  "columns": [
    "name",
    "source",
    "detail"
  ],
  "rows": [
    {
      "name": "print_exc(limit=None, file=None, chain=True)",
      "source": "Python docs",
      "detail": "shorthand for print_exception(sys.exception(), ...)"
    },
    {
      "name": "format_exc()",
      "source": "Python docs",
      "detail": "like print_exc() but returns a string"
    },
    {
      "name": "print_exception(exc)",
      "source": "Python docs",
      "detail": "prints the Traceback (most recent call last): header, entries, then the exception type and value"
    },
    {
      "name": "format_exception(exc)",
      "source": "Python docs",
      "detail": "a list of strings, each ending in a newline; joined, they match print_exception()"
    },
    {
      "name": "print_stack(limit=None)",
      "source": "Python docs",
      "detail": "prints stack trace entries from the invocation point"
    },
    {
      "name": "limit",
      "source": "Python docs",
      "detail": "prints up to that many entries if positive; otherwise the last abs(limit) entries. None prints all of them."
    },
    {
      "name": "file",
      "source": "Python docs",
      "detail": "defaults to sys.stderr when omitted or None."
    },
    {
      "name": "chain=True",
      "source": "Python docs",
      "detail": "also prints chained exceptions (__cause__ and __context__)."
    }
  ],
  "related_slugs": [
    "python-exceptions-hierarchy"
  ],
  "license": "CC-BY-4.0",
  "source_license": "PSF-2.0 (Python docs); PSF-2.0 (python/cpython (GitHub)); prose restates cited source lines in own words",
  "as_of": "2026-11-18",
  "status": "fill-draft-20261118",
  "note": "Restated from the note's GREEN sources; check those sources before relying on a value."
}