Advertisement
KShah

Untitled

Mar 30th, 2022
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. import traceback
  2.  
  3.  
  4. def force_load(file_name):
  5.     file = open(file_name + '.py', 'rt')
  6.     lines = file.readlines()
  7.     ldict = {}
  8.     while True:
  9.         try:
  10.             exec(''.join(lines), globals(), ldict)
  11.         except SyntaxError as syntax_exception:
  12.             str_index = syntax_exception.lineno
  13.         except Exception as exception:
  14.             str_index = exception.__traceback__.tb_next.tb_lineno
  15.         else:
  16.             break
  17.  
  18.         lines.pop(str_index - 1)
  19.         ldict = {}
  20.     return ldict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement