def currentframe():
 try:
  raise Exception
 except:
  return sys.exc_info()[2].tb_frame.f_back

def currentframe ( ) : try : raise Exception except : return sys . exc_info ( ) [ 2 ] . tb_frame . f_back
in python 3 .