Exception Attributes

SyntaxError.end_offset — exception attribute

Inspect the reported ending column of a syntax diagnostic. Where a normal positive source span is available, it marks the end boundary rather than an additional character to highlight. Some diagnostics use special or missing positions; handle these before slicing.

Formal Syntax & Structure

python syntaxpython
error.end_offset

Return Value

int | None

Diagnostic field when available.

Working Example

Example Snippetpython
error = SyntaxError("expected expression", ("demo.py", 3, 5, "x = ?\n", 3, 6))print(error.end_offset)
Python Reference