better_exchook

class better_exchook.Color(enable=None)[source]
Parameters:enable (bool|None) –
ColorIdxTable = {'blue': 4, 'yellow': 3, 'green': 2, 'cyan': 6, 'black': 0, 'magenta': 5, 'white': 7, 'red': 1}[source]
color(s, color=None, bold=False)[source]
Parameters:
  • s (str) –
  • color (str|None) – e.g. “blue”
  • bold (bool) –
Returns:

s optionally wrapped with ansi escape codes

Return type:

str

classmethod get_global_color_enabled()[source]
py_syntax_highlight(s)[source]
class better_exchook.DummyFrame(filename, lineno, name, f_locals=None, f_globals=None, f_builtins=None)[source]

This class has the same attributes as a code and a frame object and is intended to be used as a dummy replacement.

classmethod from_frame_summary(f)[source]
Parameters:f (FrameSummary) –
Return type:DummyFrame
class better_exchook.ExtendedFrameSummary(frame, **kwargs)[source]
better_exchook.FrameSummary[source]

alias of _Dummy

better_exchook.StackSummary[source]

alias of _Dummy

better_exchook.add_indent_lines(prefix, s)[source]
better_exchook.better_exchook(etype, value, tb, debugshell=False, autodebugshell=True, file=None, with_color=None)[source]
better_exchook.debug_shell(user_ns, user_global_ns, traceback=None, execWrapper=None)[source]
better_exchook.dump_all_thread_tracebacks(exclude_thread_ids=set([]), file=None)[source]
better_exchook.fallback_findfile(filename)[source]
better_exchook.format_tb(tb=None, limit=None, allLocals=None, allGlobals=None, withTitle=False, with_color=None)[source]
better_exchook.get_indent_prefix(s)[source]
better_exchook.get_same_indent_prefix(lines)[source]
better_exchook.get_source_code(filename, lineno, module_globals)[source]
better_exchook.grep_full_py_identifiers(tokens)[source]
better_exchook.install()[source]
better_exchook.is_source_code_missing_open_brackets(source_code)[source]
better_exchook.output_limit()[source]
better_exchook.parse_py_statement(line)[source]
better_exchook.parse_py_statements(source_code)[source]
better_exchook.pp_extra_info(obj, depthlimit=3)[source]
better_exchook.pretty_print(obj)[source]
better_exchook.print_tb(tb, file=None, **kwargs)[source]
better_exchook.remove_indent_lines(s)[source]
better_exchook.replace_tab_indent(s, replace=' ')[source]
better_exchook.replace_tab_indents(s, replace=' ')[source]
better_exchook.replace_traceback_format_tb()[source]
better_exchook.set_linecache(filename, source)[source]
better_exchook.simple_debug_shell(globals, locals)[source]
better_exchook.str_visible_len(s)[source]
Parameters:s (str) –
Returns:len without escape chars
Return type:int
better_exchook.test_add_indent_lines()[source]
better_exchook.test_get_same_indent_prefix()[source]
better_exchook.test_is_source_code_missing_open_brackets()[source]
better_exchook.test_remove_indent_lines()[source]
better_exchook.to_bool(s, fallback=None)[source]
Parameters:
  • s (str) – str to be converted to bool, e.g. “1”, “0”, “true”, “false”
  • fallback (T) – if s is not recognized as a bool
Returns:

boolean value, or fallback

Return type:

bool|T