Print current line number with Python

19 Sep 2022

Print current line number with Python

from inspect import currentframe

def get_linenumber():
    cf = currentframe()
    return cf.f_back.f_lineno

print(f"This is line number {get_linenumber()})

links

social