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()})
19 Sep 2022
from inspect import currentframe
def get_linenumber():
cf = currentframe()
return cf.f_back.f_lineno
print(f"This is line number {get_linenumber()})