Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python exception with line number

try:
    raise NotImplementedError("Not implemented")
except Exception as e:
    exception_type, exception_object, exception_traceback = sys.exc_info()
    filename = exception_traceback.tb_frame.f_code.co_filename
    line_number = exception_traceback.tb_lineno

    print("Exception type: ", exception_type)
    print("File name: ", filename)
    print("Line number: ", line_number)
Comment

exception get line number python

import traceback

try:
    print(4/0)
except ZeroDivisionError:
    print(traceback.format_exc())
Comment

PREVIOUS NEXT
Code Example
Python :: merge on index pandas 
Python :: jupyter notebook no password or token 
Python :: python change recursion depth 
Python :: conda install lxml 
Python :: print bold python 
Python :: django admin no such table user 
Python :: python search for word is in column 
Python :: python sleep random 
Python :: python list files in current directory 
Python :: download files from google colab 
Python :: mypy ignore line 
Python :: python main 
Python :: python list all csv in dir 
Python :: mp4 get all images frame by frame python 
Python :: colab save figure 
Python :: python program to find first n prime numbers 
Python :: validation split python 
Python :: request url in web scraping 
Python :: access the value in settings django 
Python :: rotation turtle python 
Python :: python delete folder 
Python :: import mean squared log error 
Python :: python reimport module after change 
Python :: plot keras model 
Python :: generate a color python 
Python :: pandas rename index 
Python :: how to select all but last columns in python 
Python :: how to check if left mousebuttondown in pygame 
Python :: degree symbol in python 
Python :: plt vertical line 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =