PyDocs

Nav

Python Language Services

get_source_segment

ast

function · Added in 3.8 (source)
  • get_source_segment(source, node, *, padded=False)
Get source code segment of the *source* that generated *node*.

If some location information (`lineno`, `end_lineno`, `col_offset`,
or `end_col_offset`) is missing, return None.

If *padded* is `True`, the first line of a multi-line statement will
be padded with spaces to match its original position.
0 Examples
No examples for ast/get_source_segment.
See Also
No see-alsos for ast/get_source_segment
0 Notes
No notes for get_source_segment