IPython allows registering a custom exception hook, which lets you do whatever you want when an error occurs.
If you want to hide the scary details of tracebacks for a bit, you might use this.
Here is an example showing a specific error message for NameErrors, and showing just the error message instead of a traceback for the rest.
Careful! Eliminating the traceback can make it a lot harder to find where the mistake is.
def polite_errors(ip, etype, evalue, tb, tb_offset=None):
if etype is NameError:
print("Oops! looks like {}."
" Did you forget something or make a typo?".format(evalue))
# elif other special errors you can make nice
else:
# fallback on just error type and message (no traceback)
print("%s: %s" % (etype.__name__, evalue))
get_ipython().set_custom_exc((Exception,), polite_errors)
undefined
Oops! looks like name 'undefined' is not defined. Did you forget something or make a typo?
{}['a']
KeyError: 'a'
1/0
ZeroDivisionError: division by zero
def foo()
pass
SyntaxError: invalid syntax (<ipython-input-5-af92d274abf2>, line 1)