how to get the current line number in python

Solutions on MaxInterview for how to get the current line number in python by the best coders in the world

showing results for - "how to get the current line number in python"
Antonio
03 Feb 2018
1from inspect import currentframe
2
3def get_linenumber():
4    cf = currentframe()
5    return cf.f_back.f_lineno
6
7print "This is line 7, python says line ", get_linenumber()