def show_code(func): if type(func) is str : code = func else : code = inspect.getsourcelines(func)[0] code = ''.join(code) print(highlight(code, PythonLexer(), Terminal256Formatter()))