Runtime Data Attributes

frame.f_lineno

Current source line of a frame. Debuggers can write it in restricted tracing contexts to request a jump; ordinary assignment is not a general control-flow operation.

Formal Syntax & Structure

python syntaxpython
frame.f_lineno

Return Value

int

Value exposed by this attribute; availability and mutability depend on the owner as described.

Working Example

Example Snippetpython
import inspectns = {'inspect':inspect}exec(compile('def f():\n    return inspect.currentframe().f_lineno','<demo>','exec'),ns)print(ns['f']())
Python Reference