On this page
inspect.getlineno
Prev: inspect.getinnerframes | Up: inspect | Next: inspect.getmembers
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getlineno
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getlineno
Signature & Overview
inspect.getlineno(frame)
Get the line number from a frame object, allowing for optimization.
Usage
import inspect
line = inspect.getlineno(inspect.currentframe())
assert isinstance(line, int) and line > 0
Gotchas
- Equivalent to
frame.f_lineno: Works cleanly inside trace/debug hooks.
REPL Inspect
from inspect import getlineno
help(getlineno)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getinnerframes Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getmembers Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/inspect/ArgInfo Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Arguments Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Attribute Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BlockFinder Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BoundArguments shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BufferFlags shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/ClassFoundException shared tags: #inspect, #stdlib