Posts

Showing posts from November, 2018

How to format IPython starck trace. (IPythonのスタックトレースを見やすくする)

Image
Problem IPython is absolutely great tool to create Python code interactively, but when I use complicated libraries like pandas or scipy, its stack trace gets very very long and it's hard to find where was the original mistake, thanks to the verbose rich texts explaining errors. Moreover, although there are several libraries which can format the stack traces, they don't work with IPython, because IPython skip standard sys.excepthook. https://stackoverflow.com/questions/1261668/cannot-override-sys-excepthook Here is how to make it work, using one of those formatting tool TBVaccine ( https://github.com/skorokithakis/tbvaccine ). I wrote following at the python initial code(script set for $PYTHONSTARTUP). try: import tbvaccine kargs = {"code_dir":os.getenv('PWD'), "isolate":True, "show_vars":False} tbvaccine.add_hook(**kargs) if get_ipython(): # IPYTHON tbv = tbvaccine.TBVaccine(**kargs) def f(*args, **argv): tbv.prin