django-planet
April 24, 2024

Python: Make line number paths with inspect

published by Adam Johnson
in blog Adam Johnson
original entry Python: Make line number paths with inspect

Many terminals and text editors support what I’ll call “line number paths” of the form <filename>:<lineno>. Opening that path, whether by clicking or passing to a CLI, opens the given file at that line.

Python’s inspect module has a couple of functions that can be combined to …