Inspect module and get traceback

Inspect method

# import required modules
import inspect
  
def fun(a,b):
    # product of 
    # two numbers
    return a*b
  
# use getsource()
print(inspect.getsource(fun))
def fun(a,b):
    # product of 
    # two numbers
    return a*b

Class hierarchy

# create classes
class A(object):
    pass
  
class B(A):
    pass
  
class C(B):
    pass
  
# not nested
print(inspect.getmro(C))  
(<class '__main__.C'>, <class '__main__.B'>, <class '__main__.A'>, <class 'object'>)