Make vars_order line a bit shorter

Co-Authored-By: Alex Hall <alex.mojaki@gmail.com>
This commit is contained in:
Alexander Bersenev 2019-05-11 16:20:38 +05:00 committed by Ram Rachum
parent c976a185bb
commit bf52d30d91
1 changed files with 2 additions and 1 deletions

View File

@ -21,7 +21,8 @@ ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
def get_local_reprs(frame, watch=()):
vars_order = frame.f_code.co_varnames + frame.f_code.co_cellvars + frame.f_code.co_freevars + tuple(frame.f_locals.keys())
code = frame.f_code
vars_order = code.co_varnames + code.co_cellvars + code.co_freevars + tuple(frame.f_locals.keys())
result_items = [(key, utils.get_shortish_repr(value)) for key, value in frame.f_locals.items()]
result_items.sort(key=lambda key_value: vars_order.index(key_value[0]))