7 karma · joined Sep 1, 2010 (16y ago) · 4 submissions
comment 16y ago · link · parent
That, plus my location requirements, plus a so-so interview, plus the fact that I wasn't particularly qualified for the job, surely led to the following "Thanks, but no thanks" followup call.
comment 16y ago · link · parent
`sys.excepthook` is how you can do that.
Without:
x = {}
def f():
print(x['foo'])
f()
# ...
Traceback (most recent call last):
File "stack.py", line 6, in <module>
f()
File "stack.py", line 4, in f
print(x['foo'])
KeyError: 'foo'
With: import sys
def short_err(exc_type, exc, tb):
sys.stderr.write("error: tracebacks too long\n")
sys.excepthook=short_err
x = {}
def f():
print(x['foo'])
f()
#...
error: tracebacks too long
So don't worry about catching exceptions if you're just printing errors.