Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python how to get current line number

#python3
from inspect import currentframe, getframeinfo

frameinfo = getframeinfo(currentframe())

print(frameinfo.filename, frameinfo.lineno)
Comment

how to get the current line number in python

from inspect import currentframe

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

print "This is line 7, python says line ", get_linenumber()
Comment

PREVIOUS NEXT
Code Example
Python :: pi in python math 
Python :: python set negative infinity 
Python :: how to check if a letter is lowercase in python 
Python :: python set remove 
Python :: pandas replce none with nan 
Python :: python merge list into string 
Python :: python program for printing fibonacci numbers 
Python :: how to use ggplot matplotlib 
Python :: datetime utcnow 
Python :: django change user password 
Python :: Python Tkinter timer animation 
Python :: pytorch freeze layers 
Python :: append record in csv 
Python :: django update model 
Python :: how to pair up two lists in python 
Python :: give answer in 6 decimal python 
Python :: how to take multiple input in list in python 
Python :: python select columns with no na 
Python :: how to load keras model from json 
Python :: python run shell command 
Python :: python size of linked list 
Python :: ImportError: No module named flask 
Python :: how to write to the end of a file in python 
Python :: remove columns from a dataframe python 
Python :: how to know the version of python using cmd 
Python :: Scaling Operation in SkLearn 
Python :: second y axis matplotlib 
Python :: plot.barh() group by 
Python :: python for else 
Python :: np confidence interval 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =